Skip to content

Instantly share code, notes, and snippets.

@m0a0t0
Created May 9, 2013 20:22
Show Gist options
  • Save m0a0t0/5550272 to your computer and use it in GitHub Desktop.
Save m0a0t0/5550272 to your computer and use it in GitHub Desktop.
test_data = '1¦2¦"Blah\nBlah\nBlah"\n4¦5¦6'
in_quote = False
data = []
row = []
cell = []
for char in test_data:
if char != '¦':
if char == '"':
in_quote = not in_quote
elif char == '\n':
if in_quote:
cell.append(char)
else:
data.append(row)
row = []
cell = []
else:
cell.append(char)
else:
row.append(cell)
cell = []
if len(row) != 0:
data.append(row)
print data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment