Ads
with open(“xxx.csv”) as f:
line = f.readline()
while line:
if line.strip() == “A,B,C,D”:
break
line = f.readline()
df = pd.read_csv(f)
with open("xxx.csv") as f:
data = []
keyword_found = False
for line in f:
if keyword_found:
data.append(line.strip().split(','))
if line.startswith("keyword"):
keyword_found = True
data.append(line[len("keyword"):].strip().split(','))
df = pd.DataFrame(data)
Ads
Ads
row_filter = (df["D"] != "") & (~df["D"].isna())
df.loc[row_filter, "H"] = df["G"]
df.loc[row_filter, ("A", "B", "C", "G")] = 'Data1', 'Data2', '', ''
df.loc[row_filter, "F"] += 1
留意番
python入唔到 01 做 INT
你要store 01, 一係就 就用到 integer 1, 一係就用 string
上面係用string 既例子
第2, 你話要搬, 我唔知你想E搬左去F之後
E應該會點