Re: Writing list of dictionaries to CSV [correction]

2015-05-06 Thread Tim Chase
On 2015-05-06 20:22, Tim Chase wrote: > As ChrisA posted earlier, you have to use Excel's Import > functionality (there are several ways to get this wizard, but not > all ways of opening a .csv trigger the wizard), then specify those > particular columns as "Text" rather than "General" Sorry, it w

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Jon Ribbens
On 2015-05-06, Denis McMahon wrote: > You need to format your CSV date into a date format that Excel > understands when it imports it. > > First thing to try would be to export some dates from excel as CSV and > see what format excel puts them in. Beware of assuming that Excel can import its ow

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Tim Chase
On 2015-05-06 23:31, Denis McMahon wrote: > On Tue, 05 May 2015 22:32:28 -0700, Kashif Rana wrote: > > thanks for the feedback. I think its problem with excel itself, > > showing wrong value. Because when I opened the csv file in text > > editor, I can see correct value but opening in excel showing

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Denis McMahon
On Tue, 05 May 2015 22:32:28 -0700, Kashif Rana wrote: > thanks for the feedback. I think its problem with excel itself, showing > wrong value. Because when I opened the csv file in text editor, I can > see correct value but opening in excel showing wrong value. What I can > do to see correct in e

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Tim Chase
On 2015-05-06 12:27, Ian Kelly wrote: > On Wed, May 6, 2015 at 12:22 PM, Tim Chase > wrote: > > On 2015-05-06 19:08, MRAB wrote: > >> You could tell it to quote any value that's not a number: > >> > >> w = csv.DictWriter(f, pol_keys, > >> quoting=csv.QUOTE_NONNUMERIC) > >> > >> It looks like

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Ian Kelly
On Wed, May 6, 2015 at 12:22 PM, Tim Chase wrote: > On 2015-05-06 19:08, MRAB wrote: >> You could tell it to quote any value that's not a number: >> >> w = csv.DictWriter(f, pol_keys, >> quoting=csv.QUOTE_NONNUMERIC) >> >> It looks like all of the values you have are strings, so they'll >> a

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Tim Chase
On 2015-05-06 19:08, MRAB wrote: > You could tell it to quote any value that's not a number: > > w = csv.DictWriter(f, pol_keys, > quoting=csv.QUOTE_NONNUMERIC) > > It looks like all of the values you have are strings, so they'll > all be quoted. > > I would hope that Excel will then treat

Re: Writing list of dictionaries to CSV

2015-05-06 Thread MRAB
t would be stupid if it didn't! :-) On Tuesday, May 5, 2015 at 9:09:40 PM UTC+4, Kashif Rana wrote: Hello Experts When I am writing list of dictionaries to CSV file, the key 'schedule' has value 'Mar 2012' becomes Mar-12. I really do not have clue why thats happening. B

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Cecil Westerhof
Op Wednesday 6 May 2015 07:32 CEST schreef Kashif Rana: > thanks for the feedback. I think its problem with excel itself, > showing wrong value. Because when I opened the csv file in text > editor, I can see correct value but opening in excel showing wrong > value. What I can do to see correct in

Re: Writing list of dictionaries to CSV

2015-05-05 Thread Chris Angelico
On Wed, May 6, 2015 at 3:32 PM, Kashif Rana wrote: > thanks for the feedback. I think its problem with excel itself, showing wrong > value. Because when I opened the csv file in text editor, I can see correct > value but opening in excel showing wrong value. What I can do to see correct > in ex

Re: Writing list of dictionaries to CSV

2015-05-05 Thread Kashif Rana
at 9:09:40 PM UTC+4, Kashif Rana wrote: > Hello Experts > > When I am writing list of dictionaries to CSV file, the key 'schedule' has > value 'Mar 2012' becomes Mar-12. I really do not have clue why thats > happening. Below is the code. > > dic

Re: Writing list of dictionaries to CSV

2015-05-05 Thread Tim Chase
On 2015-05-05 10:09, Kashif Rana wrote: > When I am writing list of dictionaries to CSV file, the key > 'schedule' has value 'Mar 2012' becomes Mar-12. How are you making this determination? Are you looking at the raw CSV output, or are you looking at the CSV file load

Re: Writing list of dictionaries to CSV

2015-05-05 Thread Matthew Ruffalo
On 2015-05-05 14:25, Skip Montanaro wrote: > More likely, viewing the CSV file in Excel, Gnumeric, or some other > spreadsheet which interprets some inputs as dates and formats them > according to its default rules. Skip This is depressingly common, and I've even received CSV and plain text data

Re: Writing list of dictionaries to CSV

2015-05-05 Thread Cecil Westerhof
Op Tuesday 5 May 2015 19:09 CEST schreef Kashif Rana: > When I am writing list of dictionaries to CSV file, the key > 'schedule' has value 'Mar 2012' becomes Mar-12. I really do not have > clue why thats happening. Below is the code. > > dic_1 = {'action&#

Re: Writing list of dictionaries to CSV

2015-05-05 Thread Skip Montanaro
On Tue, May 5, 2015 at 1:11 PM, MRAB wrote: > I'm assuming that you're reading the CSV file in a text editor, not > some other application that might be trying to be "clever" by > "interpreting" what it thinks looks a date as a date and then > displaying it differently... More likely, viewing the

Re: Writing list of dictionaries to CSV

2015-05-05 Thread MRAB
On 2015-05-05 18:09, Kashif Rana wrote: Hello Experts When I am writing list of dictionaries to CSV file, the key 'schedule' has value 'Mar 2012' becomes Mar-12. I really do not have clue why thats happening. Below is the code. dic_1 = {'action': 'permit&#x

Writing list of dictionaries to CSV

2015-05-05 Thread Kashif Rana
Hello Experts When I am writing list of dictionaries to CSV file, the key 'schedule' has value 'Mar 2012' becomes Mar-12. I really do not have clue why thats happening. Below is the code. dic_1 = {'action': 'permit', 'dst-address': '