使用批处理文件并排合并csv文件侧 [英] Merge csv file side by side using batch file

查看:209
本文介绍了使用批处理文件并排合并csv文件侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常基本的批处理命令合并的CSV文件一起,但是我需要他们合并,以使列并排不会在继续。总会有相同数目的在各文件的记录。这是基本的code我到目前为止有:

  COPY File1.csv + File2.csv CombinedFile.csv


解决方案

试试这个:

 关闭@echo
SETLOCAL EnableDelayedExpansion< File2.csv(
   FOR / Fdelims =%%一中(File1.csv)做(
      集/ p = 2号线
      回声%%一,!2号线!
   )
)> CombinedFile.csv

I have a very basic batch command to merge csv files together, however I need them merging so that the columns are side by side not continuing on. There will always be the same number of records on each file. This is the basic code I have so far:

COPY File1.csv + File2.csv CombinedFile.csv

解决方案

Try this:

@echo off
setlocal EnableDelayedExpansion

< File2.csv (
   for /F "delims=" %%a in (File1.csv) do (
      set /P line2=
      echo %%a,!line2!
   )
) > CombinedFile.csv

这篇关于使用批处理文件并排合并csv文件侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆