合并2 CSV文件,因为它是 [英] Merge 2 csv files as it is
问题描述
我要合并2 CSV文件。例如csv1文件包含第6列csv2文件包含(第6列空)7日,8日,9日columns.In合并CSV,我需要的,因为它是(第6列--first CSV和-6,7,8,9- ---第二CSV).kindly帮助我
I want to merge 2 csv files. For example csv1 file contains first six columns and csv2 file contains (first 6 columns empty) 7th,8th,9th columns.In the merged csv, i need as it is(first 6 columns --first csv and 7,8,9----second csv).kindly help me
在此先感谢
推荐答案
让我们假设file1.csv具有这种格式的行:
Let's assume that file1.csv have lines with this format:
col1,col2,col3,col4,col5,col6
和file2.csv具有这种格式的行:
and that file2.csv have lines with this format:
,,,,,,col7,col8,col9
下面的批处理文件创建与文件1 col1..col6,并从文件2 col7..col9合并文件;它假定这两个文件具有相同数目的行,而且有不为空线中的任何文件。
The Batch file below create the merged file with col1..col6 from file1, and col7..col9 from file2; it assume that both files have the same number of lines and that there are not empty lines in any file.
@echo off
setlocal EnableDelayedExpansion
< file2.csv (
for /F "delims=" %%a in (file1.csv) do (
set /P line2=
echo %%a,!line2:~6!
)
) > merged.csv
这篇关于合并2 CSV文件,因为它是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!