Thanks!
That does look helpfull, I will give it a go and see if I can get an
alternative version working.
Regards
On 23 April 2012 17:40, Don Jennings wrote:
> Remember, the keys for the dictionary in your example are simply strings.
> It just so happens that those strings are in another file.
Remember, the keys for the dictionary in your example are simply strings. It
just so happens that those strings are in another file. Read the file which
contains the specified columns and split on the comma into variable names for
your output:
with open(spec_file, 'r') as f:
outcol1, outco
On Mon, Apr 23, 2012 at 11:08 AM, Gerhardus Geldenhuis
wrote:
> Hi
> Here is my solution:
>
> def readcsvfile(filename,headerstring):
> headers = headerstring.split(',')
>
> f = open(filename, 'ro')
> csvdata = csv.DictReader(f)
> for row in csvdata:
> for column in headers[0:-1]:
>
Hi
Here is my solution:
def readcsvfile(filename,headerstring):
headers = headerstring.split(',')
f = open(filename, 'ro')
csvdata = csv.DictReader(f)
for row in csvdata:
for column in headers[0:-1]:
print row[column]+',',
print row[headers[-1]]
Regards
On 23 April 2012 15
Hi
Thanks for all the replies, I will try a the suggestions and post my
solution back.
Regards
--
Gerhardus Geldenhuis
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Mon, Apr 23, 2012 at 10:18 AM, nehal dattani wrote:
> Hi,
>
>>
>> Unfortunately I am not, this needs to happen in python.
>>
>>
>
> Please see if following helps.
>
> http://stackoverflow.com/questions/5863999/python-cut-example
>
> Regards,
> Nehal Dattani
>
>
> ___
Hi,
> Unfortunately I am not, this needs to happen in python.
>
>
>
Please see if following helps.
http://stackoverflow.com/questions/5863999/python-cut-example
Regards,
Nehal Dattani
___
Tutor maillist - Tutor@python.org
To unsubscribe or change su
On 2012/04/23 03:46 PM, Gerhardus Geldenhuis wrote:
Not quite,
I have csvfile1:
column1, column2, column3, ... column200
That is my raw data but I want to use only 5 columns for example in a
specific application.
I thus want a file with the following:
column33,column1,column5
I then want to
Yip,
Unfortunately I am not, this needs to happen in python.
Regards
On 23 April 2012 14:59, Christian Witts wrote:
> On 2012/04/23 03:46 PM, Gerhardus Geldenhuis wrote:
>
> Not quite,
>
> I have csvfile1:
> column1, column2, column3, ... column200
>
> That is my raw data but I want to use o
Not quite,
I have csvfile1:
column1, column2, column3, ... column200
That is my raw data but I want to use only 5 columns for example in a
specific application.
I thus want a file with the following:
column33,column1,column5
I then want to read the original csv file and write a new csv file with
On Mon, Apr 23, 2012 at 8:56 AM, Gerhardus Geldenhuis
wrote:
> Hi
> Appologies about the subject I could not think of a better description.
>
> I have this very simple function:
>
> def readcsvfile(filename):
> f = open(filename, 'ro')
> csvdata = csv.DictReader(f)
> for row in csvdata:
>
Hi
Appologies about the subject I could not think of a better description.
I have this very simple function:
def readcsvfile(filename):
f = open(filename, 'ro')
csvdata = csv.DictReader(f)
for row in csvdata:
print row["column3"]+','+row["column1"]
I have another inputfile that will be
12 matches
Mail list logo