Python Forum
merge two csv files into output.csv using Subprocess
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
merge two csv files into output.csv using Subprocess
#5
Hi Dead_Eye and Snippsat,

Thanks again for you help, I was looking for BCP or SCP Approach,

because with the below code, I have extracted big sql table data directly into csv .
I wanted combine both, hence answer I was looking in BCP \SCP Style.

pandas cant handle 20gb of sql data or csv data.

copy /b d:\bcp_testing\tablewithheaders.csv+d:\bcp_testing\tablewithoutheaders.csv d:\bcp_testing\TableWithout.csv

set bcp_export_server = 
set bcp_export_DB = 
set bcp_export_Schema = 
set bcp_export_Table = 

BCP"Declare @colnames Varchar(max);
select @colnames = COALESCE((@colnames+'|',")+
column_name from %bcp_export_DB%.information_Schema.COLUMNS where Table_schema='%BCP_EXPORT_HSBC_SCHEMA% and
Table_name='%bcp_export_Table%' ORDER BY ORDINAL_POSITION;select @colnames;"
queryout d:\bcp_testing\tablewithheaders.csv -c-t,-T-S%bcp_export_server%


BCP "Select * from %bcp_export_DB%.%bcp_export_Schema%.%bcp_export_Table%"
queryout d:\bcp_testing\tablewithoutheaders.csv -c-t"|",-T-S%bcp_export_server%

copy /b d:\bcp_testing\tablewithheaders.csv+d:\bcp_testing\tablewithoutheaders.csv d:\bcp_testing\TableWithout.csv
Reply


Messages In This Thread
RE: merge two csv files into output.csv using Subprocess - by mg24 - Dec-08-2022, 05:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  merge all xlsb files into csv mg24 0 364 Nov-13-2023, 08:25 AM
Last Post: mg24
  Merge all json files in folder after filtering deneme2 10 2,417 Sep-18-2022, 10:32 AM
Last Post: deneme2
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 5 1,658 Aug-28-2022, 07:11 AM
Last Post: Melcu54
  Increment text files output and limit contains Kaminsky 1 3,241 Jan-30-2021, 06:58 PM
Last Post: bowlofred
  How to merge all the files in a directory in to one file sutra 3 2,683 Dec-10-2020, 12:09 AM
Last Post: sutra
  opening files and output of parsing leodavinci1990 4 2,579 Oct-12-2020, 06:52 AM
Last Post: bowlofred
  Merge JSON Files Ugo 4 4,668 Aug-20-2020, 06:25 AM
Last Post: ndc85430
  How to get program output from subprocess.Popen? glestwid 1 2,392 Aug-19-2020, 05:44 AM
Last Post: buran
  How to read multiple csv files and merge data rajeshE 0 1,966 Mar-28-2020, 04:01 PM
Last Post: rajeshE
  error merge text files ledgreve 3 2,725 Nov-18-2019, 12:41 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020