O
O
onekrugoikov2020-06-05 14:22:22
Python
onekrugoikov, 2020-06-05 14:22:22

How to write data to csv file?

Hello guys!

Could you help me write a script that opens a csv file, selects the 28th column and splits all the characters from the link from ? with a split. I made a small script, it shows what I want to do, but how to write a new modified file?

import csv

with open('simple.csv', 'r') as f:
    incl_col = [28]
    new_csv = []
    reader = csv.reader(f, delimiter=";")

    for row in reader:
        col = str(list(row[i] for i in incl_col))
        col = col.split('?')[0]
        print(col)
        new_csv.append(col)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jesu0s, 2020-06-05
@Jesu0s

You can use pandas library to work with dataframe. All the necessary tools are there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question