The code works properly upto entering for loop and the date values is fetched. after that it returns an empty list of values for rest of the variables like time, ref1, seriel and all.
import pandas as pd
import re
# Create a Dataframe from CSV
my_dataframe = pd.read_csv('C:/Users/WI/Desktop/file.csv')
# Drop rows with any empty cells
my_dataframe.dropna(axis=0, how='any', thresh=None, subset=['date'], inplace=False)
with open("C:/Users/WDSI/Desktop/OutputFile.txt", "w") as F:
F.write("%s" %my_dataframe)
fin = open("C:/Users/WDSI/Desktop/OutputFile.txt", "r")
# print("Input file is taken")
fout = open("C:/Users/WDSI/Desktop/OutputFile1.txt", "w")
# print("Output file is taken")
for line in fin:
date = re.findall(r'(\d{4}-\d{2}-\d{2})', fin.read())
time = re.findall(r'(\s\d{2}:\d{2}:\d{2})',fin.read())
seriel=re.findall(r'(\s[A-Z][A-Z][A-Z][0-9])',fin.read())
part=re.findall(r'(\s[0-9][0-9][0-9][A-Z][0-9][0-9][0-9][0-9][0-9])',fin.read())
ref1=re.findall(r'(\s\d{16})',fin.read())
ref3=re.findall(r'(\d{9})+$',fin.read())
#print(date)
#print(time)
#print(seriel)
#print(part)
#print(ref1)
#print(ref3)
fout.write("%10s,%8s" %((date,time)))
fout.close()
when we run this code only date variable gets the value other variables like time, ref1 and all goes empty. also please help me to write date,time,serial,part,ref1,ref3 from each row of csv file. in this format the output file should be written.