ModuleNotFoundError: No module named 'StringIO'

I am Writing a Python Function to Parse CSV Lines

import csv
import StringIO
def parseCV(csvrow):
data = StringIO.StringIO(csvrow)
dataReader = csv.reader(data)
return(dataReader.next())

But it is giving following error:
ModuleNotFoundError Traceback (most recent call last)
in
3 import csv
4 from io import StringIO
----> 5 from StringIO import StringIO
6 import string
7 def parseCV(csvrow):

ModuleNotFoundError: No module named ‘StringIO’

Can someone suggest changes?

StringIO is not available in Python3. Instead use: io.StringIO

Instead of

x="1 3\n 4.5 8"        
numpy.genfromtxt(StringIO(x))

Please use:

numpy.genfromtxt(io.BytesIO(x.encode()))
2 Likes

Thank you for the clarification.