Skip to content

Instantly share code, notes, and snippets.

@ezirmusitua
Created January 31, 2019 04:16
Show Gist options
  • Save ezirmusitua/c1e605e2a5097af54336603e74df9635 to your computer and use it in GitHub Desktop.
Save ezirmusitua/c1e605e2a5097af54336603e74df9635 to your computer and use it in GitHub Desktop.
[Convert csv string to array] Convert csv string to array in python with StringIO #python
try:
# for Python 2.x
from StringIO import StringIO
except ImportError:
# for Python 3.x
from io import StringIO
import csv
scsv = """text,with,Polish,non-Latin,lettes
1,2,3,4,5,6
a,b,c,d,e,f
gęś,zółty,wąż,idzie,wąską,dróżką,
"""
f = StringIO(scsv)
reader = csv.reader(f, delimiter=',')
for row in reader:
print('\t'.join(row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment