import csv
import pandas as pd
def update(d):
fieldnames = ["CIK", "CONAME", "FYRMO","FDATE", "FORM", "SECFNAME"]
data = [] # Create temp copy of the csv file
with open(r"C:\Users\shiva\Downloads\blackcoffer\cik_list.csv", "r", newline="") as file_read:
csv_reader = csv.DictReader(file_read, fieldnames=fieldnames)
header = next(csv_reader)
for line in csv_reader: # Reading the CSV file and storing it in temp_list
data.append(line)
for line in data: # Reading each element in the list and updating the value if different from the value passed into the function
line["SECFNAME"]=("https://www.sec.gov/Archives/"+line["SECFNAME"])
with open("cik_list.csv", "w", newline="") as file_write:
csv_writer = csv.DictWriter(file_write, fieldnames=fieldnames)
csv_writer.writeheader()
csv_writer.writerows(data)
return data
d=pd.read_csv(r'C:\Users\shiva\Downloads\blackcoffer\cik_list.csv')
update(d)
Изменения, сделанные в cik_list
, не видны в файле после того, как я запишу обратно в файл. Почему не работает?