Home > Back-end >  Cleaning csv column into fixed frame
Cleaning csv column into fixed frame

Time:04-14

sorry if it the wrong place to ask

I have a csv file with 12k rows and 2 columns[date,string] one of the columns have strings in it that most of them have 1-3 template that goes like: ["name(changes every row),fixed string, number, fixed string, number] I want that every template will split into 3 columns [name, fixed_string_1 (with the number that follows it inside), fixed_string_2 (with the number that follows it inside)] and that every new row will have the same time stamp as the row it was separated from.

with what tool is it possible to do it in python ? (and macOS)

CodePudding user response:

Read the data using pandas. Then you can follow this SO thread to solve the string splitting problem: How to split a dataframe string column into two columns?

CodePudding user response:

You can use the pandas library in python to clean your data easily. and pandas documentation for CSV operations can be found at https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html

PS. the question needs more clarification. If you can post a snippet of the csv file with various different types of rows in your CSV file then I can write a snippet of code that you can use.

  • Related