OnceUponATime
OnceUponATime

Reputation: 488

How to add data to a new row in the n-th column of a CSV file in Python?

I am working with incomplete historical data and am using Python to select specific information from TXT files (e.g. via Regex) and write them to .csv tables.

Is it possible to write a certain item or a list of items to new rows in a particular column in an existing CSV file?

I can add individual strings or lists as consecutive new rows or columns to an existing table, but very often, I am only filling in "missing information".

It would be great to find a way to select the next row in the "n"-th column of a CSV table, or to select the column by name / column heading.

Upvotes: 0

Views: 59

Answers (1)

zloy_zhake
zloy_zhake

Reputation: 2787

Have you considered using Pandas?

It has convenient methods for reading and writing csv-files. Working with columns, rows, and cells is quite intuitive.

It takes a little time to understand the basics of Pandas. but if you plan to work with csv and csv-like data more than once, it is worth it.

Upvotes: 0

Related Questions