[issue27842] Order CSV header fields

2016-08-30 Thread Steve Holden

Steve Holden added the comment:

A pleasure. Pretty heavily committed at present, but all Python related so 
maybe there'll be more small positive improvements.

--

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-30 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Thanks Steve.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bb3e2a5be31b by Raymond Hettinger in branch 'default':
Issue #27842: The csv.DictReader now returns rows of type OrderedDict.
https://hg.python.org/cpython/rev/bb3e2a5be31b

--
nosy: +python-dev

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-26 Thread Steve Holden

Steve Holden added the comment:

OK, here's what I think should be close to the final patch. I've updated the 
documentation, rebuilt it and verified it reads OK, and confirmed that the new 
code passes all tests except those skipped for platform reasons (I think they 
expect a Windows environment). This includes the new test to confirm that 
ordering is retained over all 120 possible combinations of five keys.

Please let me know if any further updates are needed.

--
Added file: https://bugs.python.org/file44235/csv_full.patch

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-26 Thread Steve Holden

Steve Holden added the comment:

Is there another way? :)

Sent from my iPhone

> On 26 Aug 2016, at 12:16, Raymond Hettinger  wrote:
> 
> 
> Raymond Hettinger added the comment:
> 
> Consider using itertools.permutations() to generate the 120 cases cases.
> 
> The news entry goes into Misc/NEWS (there is not .txt extension).
> 
> --
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Consider using itertools.permutations() to generate the 120 cases cases.

The news entry goes into Misc/NEWS (there is not .txt extension).

--

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-24 Thread Steve Holden

Steve Holden added the comment:

Testing could be interesting. I'm thinking of generating five random string 
keys with a couple of rows of data, creating csv StringIOs (using pure Python) 
for all 120 combinations and verifying that they read back in the order they 
were written.

We should also test that OrderedDicts write correctly with a DictWriter and the 
same key sets.

It's a fairly haphazard test plan, so I'll be happy to hear more thorough 
suggestions. We could at a pinch reduce the number of keys to three if speed 
considerations dictate.

BTW, what happened to NEWS.txt? :)

--

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-23 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This looks like a nice improvement.  The patch needs a test and the docs need a 
versionchanged entry.

--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-23 Thread R. David Murray

R. David Murray added the comment:

I think this seems reasonable, now that OrderedDict is in C.

--
nosy: +r.david.murray
type:  -> enhancement

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-23 Thread R. David Murray

Changes by R. David Murray :


--
hgrepos:  -353

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-23 Thread Steve Holden

Steve Holden added the comment:

Sorry, deleted the originally submitted (incorrect) patch file.

--
Added file: http://bugs.python.org/file44203/csv.patch

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-23 Thread Steve Holden

Changes by Steve Holden :


Removed file: http://bugs.python.org/file44202/csv.patch

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-23 Thread Steve Holden

New submission from Steve Holden:

It's sometimes annoying that a csv.DictReader doesn't retain the field ordering 
given in the first line of the file. Sometimes it matters.

This patch converts the reader so that it returns an OrderedDict rather than a 
plain dict, thereby retaining the ordering.

All tests still pass (though I haven't yet added a test to verify that the 
field ordering *is* retained - didn't think it was worth it if the patch won't 
be added, but will happily add that test otherwise).

I have updated the documentation, but was unable in the time available to find 
out how to correctly reference the OrderedDict class so that it was correctly 
hyperlinked.

--
components: Library (Lib)
files: csv.patch
hgrepos: 353
keywords: needs review, patch
messages: 273486
nosy: holdenweb
priority: normal
severity: normal
stage: patch review
status: open
title: Order CSV header fields
versions: Python 3.6
Added file: http://bugs.python.org/file44202/csv.patch

___
Python tracker 

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