Re: How do I read .csv files

2021-03-16 Thread Gys

On 3/12/21 11:28 AM, Johann Klammer wrote:

Specifically ones with quoted strings. I'll have whitespace in
there and possibly escaped quotechars.
maybe newlines too.
Which means that pyparsing commaSeparatedList.parseString(line) won't work.

I also like to edit them for visual alignment, so there'll
be whitespaces outside the strings(more than one)
...therefore, csv.DictReader() won't work.

I'd like them read into a dict or something..


Hi Johann Klammer,
I use Pandas for handling *.csv files

pandas documentation :



Hands on example :



-hth
Gys

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


Re: file location/directory

2021-03-16 Thread Gys

On 3/14/21 7:44 PM, Quentin Bock wrote:

how can I change the path that python takes to run certain files, I'm
starting to create game and I want those in separate folders, so how can I
change it so that python runs the program with the files from that folder?


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Hi Quentin Bock,
this is a very dense subject. The simplest sulution is to create a 
MainFolder with the main module of your game. Then in that folder, 
create a SubFolder where you can store the modules your game wants to 
import.


The alternative is to use the Environment variable $PYTHONPATH



Setting Your PYTHONPATH environment variable (Linux/Unix/OsX)

Open your personal .bashrc file at /home//.bashrc
Note that this is a hidden file
Add these 2 lines :

PYTHONPATH="${PYTHONPATH}:/path/cool/python/package/"
export PYTHONPATH

These checks the settings :

import os
import sys
print(sys.path)
print(os.environ.get('PYTHONPATH', ''))

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


Re: How do I read .csv files

2021-03-16 Thread Benjamin Schollnick
The best answer is to use the CSV library, but there are wrappers around it.

For example, I use a wrapper of my own creation (csv_common.py) @ 
https://github.com/bschollnick/bas_Utilities 
.
The main benefit is that I can create variant CSV’s by just inheriting and 
redefining portions of it, very quickly.  

But, Panda’s and other tools are just as valid as well.

But I would really recommend playing with the CSV library first, and understand 
how it works, before using a wrapper or a totally different tool.  
Understanding the basics really simplifies the learning process, and gives you 
a foundation to build upon.

- Benjamin

> On Mar 16, 2021, at 8:23 AM, Gys  wrote:
> 
> On 3/12/21 11:28 AM, Johann Klammer wrote:
>> Specifically ones with quoted strings. I'll have whitespace in
>> there and possibly escaped quotechars.
>> maybe newlines too.
>> Which means that pyparsing commaSeparatedList.parseString(line) won't work.
>> I also like to edit them for visual alignment, so there'll
>> be whitespaces outside the strings(more than one)
>> ...therefore, csv.DictReader() won't work.
>> I'd like them read into a dict or something..
> 
> Hi Johann Klammer,
> I use Pandas for handling *.csv files
> 
> pandas documentation :
> 
> 
> 
> Hands on example :
> 
> 
> 
> -hth
> Gys
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: How do I read .csv files

2021-03-16 Thread The Cool Life
Try importing the CSV module. That might help!


> On Mar 16, 2021, at 6:27 AM, Gys  wrote:
> 
> On 3/12/21 11:28 AM, Johann Klammer wrote:
>> Specifically ones with quoted strings. I'll have whitespace in
>> there and possibly escaped quotechars.
>> maybe newlines too.
>> Which means that pyparsing commaSeparatedList.parseString(line) won't work.
>> I also like to edit them for visual alignment, so there'll
>> be whitespaces outside the strings(more than one)
>> ...therefore, csv.DictReader() won't work.
>> I'd like them read into a dict or something..
> 
> Hi Johann Klammer,
> I use Pandas for handling *.csv files
> 
> pandas documentation :
> 
> 
> 
> Hands on example :
> 
> 
> 
> -hth
> Gys
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I read .csv files

2021-03-16 Thread Alan Gauld via Python-list
On 16/03/2021 16:15, The Cool Life wrote:
> Try importing the CSV module. That might help!
And for the removal of doubt it is spelled csv 9lower case)

And it looks like you want to read about the DictReader
class within it.

The csv module docs include several examples.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: file location/directory

2021-03-16 Thread dn via Python-list
On 17/03/2021 02.02, Gys wrote:
> On 3/14/21 7:44 PM, Quentin Bock wrote:
>> how can I change the path that python takes to run certain files, I'm
>> starting to create game and I want those in separate folders, so how
>> can I
>> change it so that python runs the program with the files from that
>> folder?


> this is a very dense subject. The simplest sulution is to create a

+1


> MainFolder with the main module of your game. Then in that folder,
> create a SubFolder where you can store the modules your game wants to
> import.

+1
- and start the game from "MainFolder", ie make that the "current
working directory".


> The alternative is to use the Environment variable $PYTHONPATH

Why not manipulate os.path directly instead of using $PYTHONPATH?
(this might turn into a philosophical discussion...)


> Setting Your PYTHONPATH environment variable (Linux/Unix/OsX)
> 
> Open your personal .bashrc file at /home//.bashrc

The above assumes a *nux OpSys. That being an aspect of the "dense
subject"! If you (OP) intend to distribute this game to other
users/systems, then it is important to be aware of the myriad
differences and 'gotchas'.

Another such challenge is to ensure that everything-needed will be
included in the s/w-delivery - it is very easy to manually copy-over one
directory, but equally easy to forget some (non-sub-directory) companion
library.

In the case of $PYTHONPATH, you will either have to provide a mechanism
to install such for your users, or ask them to do it manually!

(hint: users want to play the game, so don't expect them to be *nix
command-line experts)
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Universal compiler that runs Java, Ruby, C++, and Python in a single VM

2021-03-16 Thread James Lu
It's called Oracle's Truffle. Truffle runs all those languages with an
autogenerated JIT.

This is my response to the neos drama.
-- 
https://mail.python.org/mailman/listinfo/python-list