Python converting UUID's from string -
i have text file includes uuids this:
a4ab4cd2-016b-411e-8ba1-0000c592bf17
when seek , parse/print file python, (but not all) end looking this:
12:40:54:457
there 3 chunks per line i'm parsing, double, date, , uuid. first 2 parts work fine. relevant lines of code are:
for line in filelines: parts = line.split() # parse first 2 chunks outputfile.write(""" tableid = '""" + uuid.uuid(parts[2]) + """'""")
this fails because uuids of form 12:40:54:547, don't know sub-type of uuid called, allow lone how appropriately parse it. goal read in uuid is, , re-print text around can run sql script.
i'm running python 3.3.2
a total line of input looks this:
339.00 2013-06-18 12:40:54.457 a4ab4cd2-016b-411e-8ba1-0000c592bf17
if uuid lastly in line, access [-1]
outputfile.write(""" tableid = '""" + uuid.uuid(parts[-1]) + """'""")
in illustration give parts[2] homecoming time. if lines consistent, can utilize parts[2], if info uuid varies, pick lastly element after split
python python-3.x uuid
No comments:
Post a Comment