Re: problem reading a CSV file

2021-12-13 Thread Greg Ewing
On 14/12/21 7:07 am, MRAB wrote: It's difficult to say what the problem is when you haven't given us the code! Note: Attachments do not make it to this list. You will need to insert the code into the message as text. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: problem reading a CSV file

2021-12-13 Thread MRAB
On 2021-12-12 23:37, Larry Warner wrote: Win 10, Chrome, Python 3.10.1 New at python error on open statement Probably simple error but I do not see it. The program is a python example with the file name being changed. I want to experiment with changing the literal file name in the open stateme

Re: problem reading a CSV file

2021-12-13 Thread Chris Angelico
On Tue, Dec 14, 2021 at 12:05 AM Larry Warner wrote: > > Win 10, Chrome, Python 3.10.1 > New at python > error on open statement > > Probably simple error but I do not see it. > > The program is a python example with the file name being changed. I want > to experiment with changing the literal fi

problem reading a CSV file

2021-12-13 Thread Larry Warner
Win 10, Chrome, Python 3.10.1 New at python error on open statement Probably simple error but I do not see it. The program is a python example with the file name being changed. I want to experiment with changing the literal file name in the open statement to a variable name later. Larry -- htt

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-27 Thread Jerry Hill
On Fri, Jun 23, 2017 at 4:07 PM, Mark Byrne wrote: > Possible fix is to replace this: > > count = frequency.get(word,0) > count1 = frequency.get(word1,0) > if word1 == word: > frequency[word] = count + count1 > else: > frequency[word] = count > > with this: > > if word1 == word: > if

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-27 Thread SANS SANTOSH
On Sat 24. Jun 2017 at 13:27, Mark Byrne wrote: > A problem (possibly the problem) is the lines which use the get function: > count = frequency.get(word,0) > > Since the dictionary is empty at the start of the loop, the get function is > passing a value of 0 to count and count1. > The subsequent

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-24 Thread mbyrnepr2
On Thursday, June 22, 2017 at 12:16:28 PM UTC+1, kishan.samp...@gmail.com wrote: > I want to write a common file in which It can add the frequency by adding > multiple csv file and if the same words are repeated in python then it should > add the frequency in the common file can any one help me p

how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-24 Thread Mark Byrne
A problem (possibly the problem) is the lines which use the get function: count = frequency.get(word,0) Since the dictionary is empty at the start of the loop, the get function is passing a value of 0 to count and count1. The subsequent updates to the dictionary are applying a value of zero As a

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-23 Thread Peter Otten
Dennis Lee Bieber wrote: > On Fri, 23 Jun 2017 09:49:06 +0300, Jussi Piitulainen > declaimed the following: > >>I just like those character translation methods, and I didn't like it >>when you first took the time to call a simple regex "line noise" and >>then proceeded to post something that loo

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-22 Thread Jussi Piitulainen
Dennis Lee Bieber writes: > On Thu, 22 Jun 2017 22:46:28 +0300, Jussi Piitulainen declaimed the > following: > >> >> A pair of methods, str.maketrans to make a translation table and then >> .translate on every string, allows to do all that in one step: >> >> spacy = r'\/-.[]{}()' >> tr = str.maket

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-22 Thread breamoreboy
On Thursday, June 22, 2017 at 12:16:28 PM UTC+1, kishan.samp...@gmail.com wrote: > I want to write a common file in which It can add the frequency by adding > multiple csv file and if the same words are repeated in python then it should > add the frequency in the common file can any one help me p

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-22 Thread Jussi Piitulainen
Dennis Lee Bieber writes: > # lowerecase all, open hyphenated and / separated words, parens, > # etc. > ln = ln.lower().replace("/", " ").replace("-", " ").replace(".", " ") > ln = ln.replace("\\", " ").replace("[", " ").replace("]", " ") > ln = ln.replace("{", " ").replace("}", " ") >

how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-22 Thread kishan . sampat . cerelabs
I want to write a common file in which It can add the frequency by adding multiple csv file and if the same words are repeated in python then it should add the frequency in the common file can any one help me please import re import operator import string class words: def __init__(self,fh)

Re: Reading a CSV file

2013-04-23 Thread Dave Angel
On 04/23/2013 06:40 PM, Ana Dionísio wrote: The condition I want to meet is in the first column, so is there a way to read only the first column and if the condition is true, print the rest? The CSV module will read a row at a time, but nothing gets printed till you print it. So starting wi

Re: Reading a CSV file

2013-04-23 Thread Fábio Santos
The enumerate function should allow you to check whether you are in the first iteration. Like so: for row_number, row in enumerate(csv.reader(<...>)): if enumerate == 0: if : break ... Enumerate allows you to know how far into the iterati

Re: Reading a CSV file

2013-04-23 Thread Ana Dionísio
The condition I want to meet is in the first column, so is there a way to read only the first column and if the condition is true, print the rest? -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading a CSV file

2013-04-23 Thread Dan Stromberg
On Tue, Apr 23, 2013 at 2:58 PM, Ana Dionísio wrote: > Thank you, but can you explain it a little better? I am just starting in > python and I don't think I understood how to apply your awnser > -- > http://mail.python.org/mailman/listinfo/python-list > #!/usr/local/pypy-1.9/bin/pypy import csv

Re: Reading a CSV file

2013-04-23 Thread Ana Dionísio
Thank you, but can you explain it a little better? I am just starting in python and I don't think I understood how to apply your awnser -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading a CSV file

2013-04-23 Thread Dan Stromberg
On Tue, Apr 23, 2013 at 2:39 PM, Ana Dionísio wrote: > Hello! > > I need to read a CSV file that has "n" rows and "m" columns and if a > certain condition is met, for exameple n==200, it prints all the columns in > that row. How can I do this? I tried to save all the data in a > multi-dimensional

Reading a CSV file

2013-04-23 Thread Ana Dionísio
Hello! I need to read a CSV file that has "n" rows and "m" columns and if a certain condition is met, for exameple n==200, it prints all the columns in that row. How can I do this? I tried to save all the data in a multi-dimensional array but I get this error: "ValueError: array is too big."

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread Robert Kern
Laurent RAHUEL wrote: > I thought you knew the number of cols and what you should expect in each. > Then it sounded pretty easy to build a list of dictionaries. If you don't > know what you're supposed to find in your file and how this file is > structured I guess you don't know what you are doing

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread Laurent RAHUEL
John Machin wrote: > Laurent RAHUEL wrote: >> RFQ wrote: >> >> >>>Hi, I'm struggling here to do the following with any success: >>> >>>I have a comma delimited file where each line in the file is something >>>like: >>> >>>PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... >> >

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread John Machin
Laurent RAHUEL wrote: > RFQ wrote: > > >>Hi, I'm struggling here to do the following with any success: >> >>I have a comma delimited file where each line in the file is something >>like: >> >>PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... > > > This is NOT a CSV file. A CS

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread Laurent RAHUEL
RFQ wrote: > Hi, I'm struggling here to do the following with any success: > > I have a comma delimited file where each line in the file is something > like: > > PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... This is NOT a CSV file. A CSV file would be : PNumber,Contracto

Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread GMane Python
Sounds like you want to use the ConfigObject module. http://www.voidspace.org.uk/python/modules.shtml#configobj -dave "RFQ" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, I'm struggling here to do the following with any success: > > I have a comma delimited file where each lin

Re: Reading a CSV file into a list of dictionaries

2005-06-06 Thread Peter Otten
RFQ wrote: > I have a comma delimited file where each line in the file is something > like: > > PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... > > So each line is intended to be: key1,value1,key2,value2,key3,value3... > and each line is to be variable in length (although it

Re: Reading a CSV file into a list of dictionaries

2005-06-06 Thread Robert Kern
RFQ wrote: > Hi, I'm struggling here to do the following with any success: > > I have a comma delimited file where each line in the file is something > like: > > PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... > > So each line is intended to be: key1,value1,key2,value2,key3,

Reading a CSV file into a list of dictionaries

2005-06-06 Thread RFQ
Hi, I'm struggling here to do the following with any success: I have a comma delimited file where each line in the file is something like: PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,... So each line is intended to be: key1,value1,key2,value2,key3,value3... and each line is