I have 3 csv files /home/project/airflow/dags/finalassignment/staging/csvdata.csv…
- User
I have 3 csv files /home/project/airflow/dags/finalassignment/staging/csv_data.csv /home/project/airflow/dags/finalassignment/staging/tsv_data.csv /home/project/airflow/dags/finalassignment/staging/fixed_width_data.csv
How do I combine them into a new csv file in the same directory using bash, so that columns from all files are on the same line based on the order they are present in each file
- Assistant
To combine the three CSV files into a new CSV file such that the columns from all files are on the same line based on the order they are present, you can use the
pastecommand in bash. This command merges lines of files horizontally.Here’s how you can do it:
- Open a terminal.
- Navigate to the directory with your CSV files or run the command directly specifying the full path.
- Run the following command:
paste -d',' /home/project/airflow/dags/finalassignment/staging/csv_data.csv \ /home/project/airflow/dags/finalassignment/staging/tsv_data.csv \ /home/project/airflow/dags/finalassignment/staging/fixed_width_data.csv \ > /home/project/airflow/dags/finalassignment/staging/combined_data.csvExplanation: