[issue32116] CSV import and export simplified

2017-11-24 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I'm also -1 on this feature request.  The open and closing of files is 
orthogonal to what you do with an open file.  Likewise, iterators are 
orthogonal to how they are consumed (for-loops, list(), set(), etc).

FWIW, csv.Reader object is an iterator that can be fed directly to list():

result = list(csv.reader(fileobj)

--
nosy: +rhettinger
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32116] CSV import and export simplified

2017-11-24 Thread Paul Long

Change by Paul Long :


--
keywords: +patch
pull_requests: +4478
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32116] CSV import and export simplified

2017-11-22 Thread Paul Long

Paul Long  added the comment:

Thanks for your advice.  The reason it's not provided as a canned function is 
because different schools can use different programming languages, although the 
vast majority choose to use Python.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32116] CSV import and export simplified

2017-11-22 Thread R. David Murray

R. David Murray  added the comment:

Um.  If they aren't expected to understand how to write this code, why isn't it 
being provided to them as a canned function as part of the test environment?

To succeed in getting something like this added, I suspect you will need to 
show that it has more general utility, or there is something analogous that can 
be added that has more general utility.  I recommend starting a discussion on 
the python-ideas mailing list.

By the way, if I needed this in my code, I'd write:

  with open(file_name, newline="") as csvfile:
  my_list = list(csv.reader(csvfile))

  with open(file_name, 'w', newline="") as csvfile:
  csv.writer(csvfile).writerows(my_list)

Only if I needed it more than once would I bother wrapping it in a function.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32116] CSV import and export simplified

2017-11-22 Thread Paul Long

Paul Long  added the comment:

I should have added that there are thousands of 15 year old students completing 
GCSE Computer Science who would benefit massively from this.  All the exam 
boards in England require students to be able to read from and write to CSV 
files.  The complicated way of doing it in Python is making this quite 
inaccessible to most students and so although many programmers in general 
wouldn't need this very often, there are literally thousands of students who 
would benefit from this enhancement.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32116] CSV import and export simplified

2017-11-22 Thread R. David Murray

R. David Murray  added the comment:

Thanks for the suggestion, but I'm -0.5.  I don't think these are compelling 
enough to be worth adding to the module API.  The number of times I've done 
this kind of operation is far smaller than the number of times I've had other 
code in both the input and output loops.  *Far* smaller.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32116] CSV import and export simplified

2017-11-22 Thread Paul Long

New submission from Paul Long :

It would be helpful if the CSV module included standard functions that simplify 
the import of CSV files to a list and the export of CSV files to a list.  
Here's an example of what they could be:

def csv2list(file_name): 
list_name=[] 
with open(file_name) as csvfile:
readerfile = reader(csvfile)
for row in readerfile:
list_name.append(row)
return list_name

def list2csv(list_name,file_name):
with open(file_name, 'w', newline='') as csvfile:
writerfile = csv.writer(csvfile)
writerfile.writerows(list_name)

--
components: Library (Lib)
messages: 306746
nosy: paullongnet
priority: normal
severity: normal
status: open
title: CSV import and export simplified
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com