i seem to be a little confused on what to do. I have 3 csv files, each have the the common rows of name age and sex. First csv file shows the common data of the 3 and proceeds to have card details belonging to each user, 2nd csv file contain the same 3 common details and proceeds to contain vehicle details while the third csv file is the same and then proceed to have extra details of marital status. Now i want to upload all three in a single table to be queried on mysql with python for a project. Would it be wise of me to upload all three tables and use a join query to join all three tables or do i find a python code to merge all three tables and upload on the database. I am pretty new to this so if you can explain simple for me that would be appreciated.
if i’m gonna use a python code to merge them any ideas what would work ?
first_Name,Last_Name,Age,Sex,Vehicle_make,Vehicle_model,Vehicle_year,Vehicle_type
firstName,lastName,age,iban,credit_card_number,credit_card_security_code,credit_card_start_date,credit_card_end_date,address_main,address_city,address_postcode
firstName,lastName,age,sex,retired,dependants,marital_status,salary,pension,company,commute_distance,address_postcode
here is what each row looks like and the need to merge them all. I’d also need to find a way to sort out which i could use a primary key. i have about 3-4 rows that will have identical details so i cant really say which i could use.
any ideas would be great.
2
Answers
Try use Pandas to merge your data like this:
You can not only save merged frame to csv but directly to database with df.to_sql() method. Also it is possible to manipulate with your data as you wish.
Try to solve your problem using standard Python tools
It’s not so elegant but should works.