N
N
novicheck2016-08-17 19:10:19
Python
novicheck, 2016-08-17 19:10:19

Why does the csv file have a strange notation?

I have to find the dates of the paid actions and the start of the game and write them into a CSV file and I did it, but in the final file the data looks strange. Non-null arrays have quotes. Will this affect subsequent data processing? Sample data:

6443d279-b639-4f54-ab8c-63184d272c40,"[datetime.timedelta(37, 65380)]"
BA359878-6920-495C-8839-452DEB17DA7F,"[datetime.timedelta(1, 65086), datetime.timedelta(1, 64760), datetime.timedelta(1, 64393)]"
817E69C6-4481-4E64-A057-EA8D289B1848,"[datetime.timedelta(15, 1145)]"
55DE6081-2A40-4A72-9976-06F35D4C3A8C,[datetime.timedelta(0)]
a8869fa9-2a58-40f6-bcdc-e656a47609f6,"[datetime.timedelta(0, 27), datetime.timedelta(0)]"
09F66930-0C0B-4973-9BE1-ABBB797B1B81,"[datetime.timedelta(4, 26275)]"
7B078A74-EBAD-4559-8D7A-4D6D0E290300,"[datetime.timedelta(0, 82465), datetime.timedelta(0, 82813), datetime.timedelta(0, 61156), datetime.timedelta(0, 61118), datetime.timedelta(0, 52847), datetime.timedelta(0, 82760), datetime.timedelta(0, 40056), datetime.timedelta(0, 52749), datetime.timedelta(0, 42324), datetime.timedelta(0, 42290), datetime.timedelta(0, 52796), datetime.timedelta(0, 39366), datetime.timedelta(0, 42254), datetime.timedelta(0, 39911), datetime.timedelta(0, 39871), datetime.timedelta(0, 39332), datetime.timedelta(0, 61047), datetime.timedelta(0, 61081), datetime.timedelta(0, 39279), datetime.timedelta(0, 61185), datetime.timedelta(0, 28103), datetime.timedelta(0, 33380), datetime.timedelta(0, 33425)]"
34486AFD-0DF6-4ECE-AE34-A8AE73172FC5,[datetime.timedelta(0)]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
clx, 2016-08-17
@clx

Всё нормально, кавычки для экранирования запятой в данных.

R
Roman Kitaev, 2016-08-17
@deliro

Нет. Используй csv модуль и не придётся задумываться об экранировании.
Хотя, формат и правда странный, хранить в CSV записи такого вида: datetime.timedelta(0, 82465)
Их придётся либо парсить, либо использовать eval, что очень и очень не рекомендуется.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question