Jan-25-2023, 04:12 PM
@buran
This is perfect....
Thank you so much!!
This is perfect....
Thank you so much!!
(Jan-25-2023, 02:18 PM)buran Wrote: read the whole file in memory and replace\n
with just""
import pandas as pd from io import StringIO file_path = r'path-to-file\test_CSV_file.csv' with open(file_path, 'r') as f: data = f.read().replace('\n ', ' ') df = pd.read_csv(StringIO(data)) print(df)output
If you want you can write
Output:SOURCE CATEGORY PERIOD_NAME BATCH_NAME JOURNAL_NAME 0 3 7 Sep-22 ext002 EP A 5005720 1167 EP 23-SEP-2022 Receipts 1 3 7 Sep-22 ext002 EP A 5005720 1167 EP 23-SEP-2022 Receipts 2 3 7 Apr-22 ext001 EP A 4926954 1068 EP 21-APR-2022 Receipts 3 3 7 Apr-22 ext001 EP A 4926954 1068 EP 21-APR-2022 Receipts 4 3 6 Apr-22 ext001 EP A 4926954 1068 EP 21-APR-2022 Deposits 5 3 7 Aug-22 ext002 EP A 4962225 1131 EP 03-AUG-2022 Receiptsdata
back to file in order to fix it, instead of usingio.StringIO
to directly work with data in pandas