0

Below is the current code that yields extra spaces after appending logs/events:

import csv

#MANUAL ENCODES

logs = [["TT5134", "XACG2M756B2ZP0", "2055243", "ref die", "abort;play", "closed"]
        ]

#FILE DUMP

with open(r"\\xcl3090dm1\checkout_eagle\ETS\PE_Downs(DONOTDELETE)\SR_Data.csv", "a") as csv_file:

    reports = csv.writer(csv_file)

    reports.writerows(logs)

Assuming I have next logs/event to input, there will be space produce. How can I use the strip() function on my existing code? I tried to insert this function but I either failing to remove the space or producing errors.

logs with row spaces

norok2
  • 25,683
  • 4
  • 73
  • 99
jaypeeee10
  • 21
  • 3

1 Answers1

0

Use Pandas

import pandas as pd
pd.read_csv("\xcl3090dm1\checkout_eagle\ETS\PE_Downs(DONOTDELETE)\SR_Data.csv", sep=',',header=0)

If necessary:

df.dropna(inplace=True)
razimbres
  • 4,715
  • 5
  • 23
  • 50