def read_string_io_csv(file_name, headers): with open(file_name, encoding="utf8") as csvfile: csv_reader = csv.reader(csvfile, delimiter=',', quotechar='"', skipinitialspace=True, doublequote=False, quoting=csv.QUOTE_ALL, escapechar='\\') line_count = 0 data = [] num_of_col = len(headers) for row in csv_reader: data_row = {} for col in range(num_of_col): data_row[headers[col]] = row[col] data.append(data_row) line_count += 1 return pd.DataFrame(data)