I am trying to read the first column of a CSV file and see if it meets requirements. If it meets the requirements, I want to write it to one of the following column.
As you can see from my code, i have the reading working (although not sure if the best method) I just need to get it to write to the 3 column in that row.
Example: If any row in the first column contains a 4 digit value that starts with 25, enter a Y into the 3 column of that row.
CSV Example:
number,na,prefix25,na,na,na
1000,,,,,
1254,,,,,
251,,,,,
2501,,,,,
6548,,,,,
1478,,,,,
02,,,,,
2550,,,,,
2569,,,,,
Desired CSV output:
number,na,prefix25,na,na,na
1000,,,,,
1254,,,,,
251,,,,,
2501,,y,,,
6548,,,,,
1478,,,,,
02,,,,,
2550,,y,,,
2569,,y,,,
Code so far:
def micro():
#Prefix 25
with open(dbPath) as f:
reader = csv.reader(f, delimiter="\t")
for i in reader:
if len(i[0]) == 4:
curStore = i[0].startswith("25")
if curStore is True:
#Prints found numbers what are 4 digits and start with 25
print(i[0])
Thanks in advance for any assistance