This is driving me nuts.
I have tried many different things, but I just do not understand this csv
library.
I have tried passing various parameters to the writerow method and I am really
getting nowhere fast.
I just want to read from a file, join text to column and write to file.
The wr
Hi,
On 20 June 2014 09:38, Ian D wrote:
> #so far this should read a file
> #using dictreader and take a column and join some text onto it
>
> import csv
>
> csvfile= open('StudentListToSort.csv', newline='')
> spamreader = csv.DictReader(csvfile,delimiter=',',quotechar='|')
>
> #open a file to w
Thanks for your help
I am not much closer in understanding this so I am going to try and start with
a simpler example for myself.
I will try and write some values to a file as I am struggling even doing this.
TypeError: 'str' does not support the buffer interface
TypeError: 'tuple' does not
Hi,
Firstly an apology -- I only just noticed your original code was
Python 3 -- my example was Python 2, so there would be some changes
required to make the example work on Python 3...
On 20 June 2014 11:19, Ian D wrote:
> Thanks for your help
>
>
> I am not much closer in understanding this so
Thanks
>
> Nonetheless, having re-read your question and having googled a bit, it
> seems that your problem might be related to Python 2 vs. Python 3, see
> here:
> http://stackoverflow.com/questions/24294457/python-typeerror-str-does-not-support-the-buffer-interface
>
> In short: In Python 2 you
Ok making some progress by changing the 'wb' to 'w'
>
> Ok I see this error and the example shows a different type of syntax.
>
>
> Rather than a file open for writing:
>
> outfile = open('output.csv', 'wb')
>
>
> it uses
>
> with open('data.csv', 'w', newline='') as out:
>
>
>
> now is this writ
>
> Ok making some progress by changing the 'wb' to 'w'
>
err no.
unstuck again.
import csv
csvfile= open('StudentListToSort.csv', newline='')
spamreader = csv.reader(csvfile,delimiter=',',quotechar='|')
outfile = open('outfile.csv','w')
for row in spamreader:
if row[4] == '6':
On 20/06/2014 15:11, Ian D wrote:
Ok making some progress by changing the 'wb' to 'w'
err no.
unstuck again.
import csv
csvfile= open('StudentListToSort.csv', newline='')
spamreader = csv.reader(csvfile,delimiter=',',quotechar='|')
outfile = open('outfile.csv','w')
for row in spamreader
Hi,
You've had a very good reply from Mark already however I want to add
to it and further clarify what he pointed out (why exactly *are* you
getting the tuple error after all?), also I've updated the prior
example to help explain, see below:
On 20 June 2014 15:11, Ian D wrote:
>
> import csv
>
On 2014-06-19 15:52, Steven D'Aprano wrote:
On Thu, Jun 19, 2014 at 11:10:26AM -0700, Alex Kleider wrote:
The idea of a singleton class is new to me as is this comparison of
class vs module.
Can anyone suggest a place to turn for more discussion of the topic?
thks, alexK
"Singleton" is one o
On Fri, Jun 20, 2014 at 08:38:52AM +, Ian D wrote:
> This is driving me nuts.
>
> I have tried many different things, but I just do not understand this
> csv library.
Have you tried reading the documentation? It sounds like you're just
throwing random bits of code at it and hoping something
11 matches
Mail list logo