Pandas: Multiple CSVs in one Zip file

2021-08-26 Thread Abdur-Rahmaan Janhangeer
Greetings,

Cannot read one file in a zip file if the zip file contains multiple files.

This example does not work https://www.py4u.net/discuss/203494 as Pandas
shows a ValueError: Multiple files found in ZIP file. Only one file per ZIP.

If the Zip file has one file, fine else i cannot find a way. Thanks

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

github 
Mauritius
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas: Multiple CSVs in one Zip file

2021-08-26 Thread Peter Otten

On 26/08/2021 09:09, Abdur-Rahmaan Janhangeer wrote:


Cannot read one file in a zip file if the zip file contains multiple files.

This example does not work https://www.py4u.net/discuss/203494 as Pandas
shows a ValueError: Multiple files found in ZIP file. Only one file per ZIP.

If the Zip file has one file, fine else i cannot find a way. Thanks


You may have introduced an error when you translated the snippet to your 
use case. What went wrong is hard to guess unless you provide the exact 
failing code.


Pandas can read a single zipped file out of the box and the accepted 
answer in your indirect link to


https://stackoverflow.com/questions/61971040/python-extract-csv-files-from-multiple-zip-files-and-combine-the-data

shows how to deal with zip files containing multiple files.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas: Multiple CSVs in one Zip file

2021-08-26 Thread Peter J. Holzer
On 2021-08-26 11:09:21 +0400, Abdur-Rahmaan Janhangeer wrote:
> Cannot read one file in a zip file if the zip file contains multiple files.
> 
> This example does not work https://www.py4u.net/discuss/203494 as Pandas
> shows a ValueError: Multiple files found in ZIP file. Only one file per ZIP.
> 
> If the Zip file has one file, fine else i cannot find a way. Thanks

Is it possible that you are trying to treat the zip file as a gzip file?
Those are different file formats with different purposes (archive vs.
stream), but they use the same compression algorithm, and the gzip tool
(and - I presume - also the gzip library) can read a zip file with a
single member. The error message would match that.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


configargparse - reading option from config only

2021-08-26 Thread Loris Bennett
Hi,

When using configargparse, it seems that if a value is to be read from a
config file, it also has to be defined as a command-line argument in
order to turn up as an attribute in the parser namespace.  

I can sort of see why this is the case, but there are also some options
I would like to read just from the config file and not have them
available as command-line options.  This would be, say, to prevent the
number of options on the command-line from becoming bloated by
little-used settings.

Is there an elegant way to do this?

Cheers,

Loris

-- 
This signature is currently under construction.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Making command-line args available to deeply-nested functions

2021-08-26 Thread Loris Bennett
George Fischhof  writes:

[snip (79 lines)]

>> > Hi,
>> >
>> > Also you can give a try to click and / or  typer packages.
>> > Putting args into environment variables can be a solution too
>> > All of these depends on several things: personal preferences, colleagues
>> /
>> > firm standards, the program, readability, variable accessibility (IDE
>> > support, auto completition) (env vars not supported by IDEs as they are
>> not
>> > part of code)
>>
>> Thanks for the pointers, although I have only just got my head around
>> argparse/configargparse, so click is something I might have a look at
>> for future project.
>>
>> However, the question of how to parse the arguments is somewhat separate
>> from that of how to pass (or not pass) the arguments around within a
>> program.

[snip (16 lines)]
>
> Hi,
> I thought not just parsing, but the usage method: you add a decorator to
> the function where you want to use the parameters. This way you do not have
> to pass the value through the calling hierarchy.
>
> Note: typer is a newer package, it contains click and leverages command
> line parsing even more.

Do you have an example of how this is done?  From a cursory reading of
the documentation, it didn't seem obvious to me how to do this, but then
I don't have much understanding of how decorators work.

Cheers,

Loris


-- 
This signature is currently under construction.
-- 
https://mail.python.org/mailman/listinfo/python-list


matplotlib questions

2021-08-26 Thread Steve
I am trying to modify the "Bar Graph Demo" at
https://matplotlib.org/stable/gallery/index.html,  Lines, bars, and markers
but the more I experiment and change the code, the more messed up it
becomes.  I have the demo code working. This is my second attempt.  I guess
I accidentally got my first chart working but this second one, not so good.

Is there any source to help me understand how the code works and how to
change it?
Among many others options, how do I change the font size? 
How are the labels placed on the X-axis and Y-axis?





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-08-26 Thread Mostowski Collapse

Having fun with a new attended query answerer for
the Dogelog runtime. It can be bottled into a single Python
file, no server roundtrip, just ISO core Prolog in one

Python file, requires Python 3.10:

>python.exe toplevel.py
Dogelog Runtime, Prolog to the Moon, 0.9.3
(c) 1985-2021, XLOG Technologies AG, Switzerland
?- X=1; X=2.
X = 1;
X = 2.
?- X= ... ; X = ... .
X = ...;
X = ... .
?-

So we adopted displaying a dot when there are no more
choice points. This is seen in SWI-Prolog for example, but
was also adopted by Scryer Prolog recently.

Note the space between '...' and '.' in the last answer of
the last query. This is needed so that what is shown
is copyable. The query answerer is described here:

Dogelog Runtime attended Prolog query answers. (Jekejeke)
https://twitter.com/dogelogch/status/1430647215928877065

Dogelog Runtime attended Prolog query answers. (Jekejeke)
https://www.facebook.com/groups/dogelog
--
https://mail.python.org/mailman/listinfo/python-list


Re: matplotlib questions

2021-08-26 Thread Mats Wichmann

On 8/26/21 9:47 AM, Steve wrote:

I am trying to modify the "Bar Graph Demo" at
https://matplotlib.org/stable/gallery/index.html,  Lines, bars, and markers
but the more I experiment and change the code, the more messed up it
becomes.  I have the demo code working. This is my second attempt.  I guess
I accidentally got my first chart working but this second one, not so good.

Is there any source to help me understand how the code works and how to
change it?
Among many others options, how do I change the font size?
How are the labels placed on the X-axis and Y-axis?


https://matplotlib.org/stable/api/matplotlib_configurations_api.html

--
https://mail.python.org/mailman/listinfo/python-list


Re: configargparse - reading option from config only

2021-08-26 Thread tuxifreund
Hello,

you could use the argparse module[1] to parse command line arguments and 
configparser[2] to parse configuration files following the ini file 
structure. Is that what you are expecting?

Cheers


[1]: https://docs.python.org/3/library/argparse.html
[2]: https://docs.python.org/3/library/configparser.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: configargparse - reading option from config only

2021-08-26 Thread Richard Damon
On 8/26/21 6:01 AM, Loris Bennett wrote:
> Hi,
>
> When using configargparse, it seems that if a value is to be read from a
> config file, it also has to be defined as a command-line argument in
> order to turn up as an attribute in the parser namespace.  
>
> I can sort of see why this is the case, but there are also some options
> I would like to read just from the config file and not have them
> available as command-line options.  This would be, say, to prevent the
> number of options on the command-line from becoming bloated by
> little-used settings.
>
> Is there an elegant way to do this?
>
> Cheers,
>
> Loris
>
Look at the read() member function to supply the file name to read. Then
in the config object there will be sections for each section in the
config file. No need for any of these to be 'options'

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list