facebook - python csv write string into 1 cell -
i using facebook api time, convert different format, , write csv file. works except when string gets written, separates string 2 different cells so:
help me 1 cell please. thanks.
my code:
import csv datetime import * time import * facepy import * token = 'caaerzazahdbyaba............' graph = graphapi(token) g = graph.get('apple/posts?limit=4') mytime = g['data'][0]['created_time'] ctime = datetime(*strptime(mytime, "%y-%m-%dt%h:%m:%s+0000")[0:6]).strftime("%b %d, %y %i:%m %p") open('csvtest.csv', 'a') csvfile: spamwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.quote_minimal) spamwriter.writerow([ctime])
the problem you're using quotechar='|'
, spreadsheet program isn't understanding quote character.
you can see pretty output. 2 cells not july 17
, 2013 03:53 pm
; they're |july 17
, 2013 03:53pm|
.
so, either use quote character spreadsheet knows how use—the default of "
should fine—or change import settings use in spreadsheet tell use bizarre choice instead of defaults.
if used default csv
parameters, excel, numbers, oo.o, , libre, , other spreadsheet can find, have no problem date field.
Comments
Post a Comment