У меня есть файл CSV, который разделен пробелом. При импорте в Python я перепробовал каждый существующий код, чтобы определить пробел как разделитель. Однако я продолжаю получать сообщения об ошибках. Например:
Код: Выделить всё
test_filepath = 'test_data.csv'
with codecs.open(test_filepath, "r", "Shift-JIS", "ignore") as file: # import UTF8 based csv file
test_df = pd.read_table( file, delim_whitespace=True )
Код: Выделить всё
EmptyDataError: No columns to parse from file
Код: Выделить всё
test_filepath = 'test_data.csv'
with codecs.open(test_filepath, "r", "Shift-JIS", "ignore") as file: # import UTF8 based csv file
test_df = pd.read_table( file, delimiter=" " )
когда я пробую это:
Код: Выделить всё
test_filepath = 'test_data.csv'
with codecs.open(test_filepath, "r", "Shift-JIS", "ignore") as file: # import UTF8 based csv file
test_df = pd.read_table( file, sep = "/s+" )
Когда я пробую это:
Код: Выделить всё
test_filepath = 'test_data.csv'
with codecs.open(test_filepath, "r", "Shift-JIS", "ignore") as file: # import UTF8 based csv file
test_df = pd.read_table( file, delimiter='\t')
ЕДИНСТВЕННЫЙ СПОСОБ не получить ошибку — это сделать следующее:
Код: Выделить всё
test_filepath = 'test_data.csv'
with codecs.open(test_filepath, "r", "Shift-JIS", "ignore") as file: # import UTF8 based csv file
test_df = pd.read_table( file, delimiter=',')
Мобильная версия