Hi,
Sorry for delay in reply(as internet was very slow from past two
days), I tried this code which you suggested (by saving it in a file):
import csv
with open('19162.csv') as f:
reader = csv.reader(f)
for row in reader:
print(row)
row[0] = int(row[0])
key,value =
First, the error message means 'item' is missing. You will need to assign
your row as the item.
And if you want nil where there is no value, then use if statement to check
there is something otherwise make that empty value 'nil'.
Sorry, gotta run my train just arrived.
On Thu, 9 Jan 2014 14:51:21 +0800, Amrita Kumari
amrita@gmail.com wrote:
days), I tried this code which you suggested (by saving it in a
file):
import csv
with open('19162.csv') as f:
reader = csv.reader(f)
for row in reader:
print(row)
row[0] = int(row[0])
On Mon, Jan 06, 2014 at 04:57:38PM +0800, Amrita Kumari wrote:
Hi Steven,
I tried this code:
import csv
with open('file.csv') as f:
reader = csv.reader(f)
for row in reader:
print(row)
row[0] = int(row[0])
up to this extent it is ok; it is ok it is giving
Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is what
you're trying to do... I've never even opened a .txt file in Python before,
so you can take all this with a big grain of salt... Anyway, if you take
your example of your original database:
1 GLY HA2=3.7850 HA3=3.9130
2
oops, I see Steven pointed out a much cleaner approach. Oh well. Shock
surprise ;)
Keith
On Mon, Jan 6, 2014 at 3:27 AM, Keith Winston keithw...@gmail.com wrote:
Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is
what you're trying to do... I've never even opened a .txt
Hi Steven,
I tried this code:
import csv
with open('file.csv') as f:
reader = csv.reader(f)
for row in reader:
print(row)
row[0] = int(row[0])
up to this extent it is ok; it is ok it is giving the output as:
['1' , ' GLY' , 'HA2=3.7850' , 'HA3=3.9130' , ' ' , ' '
Amrita, it doesn't seem like the code you are providing is the code you are
running. I wonder if you are running it all at the Python command line or
something, and have to type it in every time? You should put it in a file,
and save run that file, and then cut and paste it directly into your
On 06/01/14 08:57, Amrita Kumari wrote:
up to this extent it is ok; it is ok it is giving the output as:
['1' , ' GLY' , 'HA2=3.7850' , 'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
[ '2' , 'SER' , 'H=8.8500' , 'HA=4.3370' , 'N=115.7570' , ' ' , ' '
, ' ']
--
Sorry I forgot to add tutor mailing list.please help for the below.
-- Forwarded message --
From: Amrita Kumari amrita@gmail.com
Date: Fri, Jan 3, 2014 at 2:42 PM
Subject: Re: [Tutor] arrangement of datafile
To: Evans Anyokwu onyx...@gmail.com
Hi,
I have saved my data
Hi Amrita, I'm just a beginner but I notice that, after the first two
entries on each line (i.e. 10,ALA), the rest might fit nicely into a dict,
like this {H: 8.388, HB1: 1.389, ...}. That would give you a lot of
flexibility in getting at the values later. It would be easy enough to
replace the =
I should have included an example. If you can, and if it doesn't make your
file too long, and if I'm right that this is easy to do in the output
module of wherever this is coming from, add some white space so you can
read/debug easier, though it's not at all necessary (strings have to be
quoted
Hi Amrita,
On Sun, Jan 05, 2014 at 10:01:16AM +0800, Amrita Kumari wrote:
I have saved my data in csv format now it is looking like this:
If you have a file in CSV format, you should use the csv module to read
the file.
http://docs.python.org/3/library/csv.html
If you're still using Python
Amrita, on a closer read of your very first post I (think I) see you
already successfully read your data into a series of dicts (mylist in your
example), so if you still want the output you posted in the first post,
then you can do some version of the loops that I described. That said, I'm
sure
14 matches
Mail list logo