Gus
Gus

Reputation: 85

Classifying raw data into csv . python

I'm a real beginner in python and i was asked to use it to retrieve some data. I manage to get them but now I need to file them in an excel tab or a csv that could be used later on. The data I have were in this format: 2005-02-04T01:00:00+02:00,1836.910000@2005-02-05T01:00:00+02:00

I managed doing this to classify them better

>>> date_value = np.array( [ (dateutil.parser.parse(d), float(v))
...                       for d,v in [l.split(',') for l in values.text.split('@')]] )
>>>ts = pd.Series(date_value[:,1],index=date_value[:,0])

>>> ts

and now I got them on this format:

2005-02-04 01:00:00+02:00 1836.91

2005-02-05 01:00:00+02:00 1821.45

And now I can't find a way to store them as an excel or csv file. If you have any advice...?

Thanks G.

Upvotes: 1

Views: 683

Answers (1)

e4c5
e4c5

Reputation: 53734

Since you seem to have quickly figured out how to use pandas to read data, the next step is to use it to write CSV. and that's done with:

pandas.DataFrame.to_csv

Excel is perfectly able to read CSV files, no need to convert to excel yourself. However if this is really a project requirement,

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_excel.html

Upvotes: 1

Related Questions