导入非标准csv文件

时间:2016-10-10 17:20:51

标签: excel csv import powerquery

我的任务是将多个csv文件导入到一个excel文件中。 似乎很容易......

那里有一个曲线球。

csv不是列标题的标准行,而是数据行。 他们更多:
列标题,值
列标题,值

转换表没问题吧.... 那么这里是第二个曲线球 列标题a,值a
列标题b,值b
列标题c,值c,标题c2,值c2
列标题d,值d,标题d2,值d2

Screenshot of File 1 imported to excel (注意突出显示的区域。)

我最终需要的是:

标题a,标题b,标题c,标题c2,标题d,标题d2
值a,值b,值c,值c2,值d,值d2

Screen shot of file 1 data manipulated

我使用Excel和电源查询,但我不确定如何清理它。

file1.csv

File Name,iqt csv file.csv,,,<br>
,Date File Extracted,10/7/2016 10:07,,<br>
Software Version,V215,,,<br>
,,,,<br>
Turns,0.244,,,<br>
Close Torque,Rated,,,<br>
Open Torque,Rated,,,<br>
Open On,LIMIT,,,<br>
Close On,LIMIT,,,<br>
Close Direction,CLOCKWISE,,,<br>
Power Loss Inhibit,OFF,,,<br>
Interrupter Timer,OFF,,,<br>
Conditional Control,OFF,,,<br>
1 Sec Control,OFF,,,<br>
5% Boost,OFF,,,<br>
ESD Mode,STATIONARY,,,<br>
ESD Signal,ACTIVE LOW,,,<br>
ESD Tstat Bypass,OFF,,,<br>
ESD Interlock Bypass,ON,,,<br>
ESD Local Stop Bypass,OFF,,,<br>
ESD Interrupter Timer Override,OFF,,,<br>
Remote Source,BOTH,,,<br>
Two Wire Control Priority,STATIONARY,,,<br>
Power Supply,SINGLE PHASE MAINS,,,<br>
Local Control,SELF MAINTAINED,,,<br>
S1,Contact,NO,Trip On,CLOSE END POSITION<br>
S2,,NO,,OPEN END POSITION<br>
S3,,NC,,CLOSE END POSITION<br>
S4,,NC,,OPEN END POSITION<br>
S5,,NO,,CLOSE END POSITION<br>
S6,,NO,,OPEN END POSITION<br>
S7,,NO,,TORQUE TRIP ANY POSITION<br>
S8,,NO,,REMOTE SELECTED<br>
LED Close Colour,GREEN,,,<br>
LED Mid Travel Indication,ON,,,<br>
CPT (If fitted),20mA,OPEN,4mA,CLOSED<br>
Partial Stroke Feature,DISABLED,,,<br>
Fetterolf,DISABLED,,,<br>
 ,,,,<br>
Option Fitted,PROFIBUS,,,<br>
Action on Loss of Comms,,,,<br>
Off,,,,<br>
Limited Range Position Minimum,0,%,,<br>
Limited Range Position Maximum,0,%,,<br>
Deadband,0,%,,<br>
Motion Inhibit Time,0,s,,<br>
Address Change,TRUE,,,<br>
Address,0,,,<br>
Auxilliary Inputs,,,,<br>
Aux 1,Report 1 for o/c,,,<br>
Aux 2,Report 1 for o/c,,,<br>
Aux 3,Report 1 for o/c,,,<br>
Aux 4,Report 1 for o/c,,,<br>
Signal Loss Timeout,0,s,,<br>
Manufacturing Data,,,,<br>
Serial Number,B412510101,,,<br>
Wiring Diagram,WD19595-01,,,<br>
Type & Size,IQTM250,,,<br>
Base,FA10,,,<br>
Enclosure,30,,,<br>
Voltage,WT,,,<br>
Month/Year,480360,,,<br>
Speed,209,,,<br>
Test Rig,RF1,,,<br>
Operator Notes,,,,<br>
,.....................,,,<br>
,....................,,,<br>

file2.csv

"File Name","iqtConfigCSVFileBlank.csv"<br>
"","Date File Extracted","10/10/2016 9:16:27 AM "<br>
<br>
<br>
"Turns",0<br>
"Close Torque %",40<br>
"Open Torque %",40<br>
"Open On","TORQUE"<br>
"Close On","TORQUE"<br>
"Close Direction","CLOCKWISE"<br>
"Power Loss Inhibit","ON"<br>
"Interrupter Timer","OFF"<br>
"Conditional Control","OFF"<br>
"1 Sec Control","OFF"<br>
"5% Boost","OFF"<br>
"ESD Mode","CLOSE"<br>
"ESD Signal","ACTIVE LOW"<br>
"ESD Tstat Bypass","OFF"<br>
"ESD Interlock Bypass","OFF"<br>
"ESD Local Stop Bypass","OFF"<br>
"ESD Interrupter Timer Override","OFF"<br>
"Remote Source","OFF"<br>
"Two Wire Control Priority","CLOSE"<br>
"Power Supply","3 PHASE MAINS"<br>
"Local Control","SELF MAINTAINED"<br>
"S1","Contact","NC","Trip On","INTERMEDIATE POSITION",50,"%"<br>
"S2","","NC","","INTERMEDIATE POSITION",50,"%"<br>
"S3","","NC","","INTERMEDIATE POSITION",50,"%"<br>
"S4","","NC","","INTERMEDIATE POSITION",50,"%"<br>
"LED Close Colour","GREEN"<br>
"CPT (If fitted)","20mA","OPEN","4mA","CLOSED"<br>
"Partial Stroke Feature","DISABLED"<br>
"Fetterolf","DISABLED"<br>
" "<br>
"Manufacturing Data"<br>
"Operator Notes"<br>
"NO USER NOTE FITTED"<br>
<br>
<br>

感谢您的光临。

1 个答案:

答案 0 :(得分:0)

查看您提供的文件示例内容看起来相当标准。它为我自动加载而没有任何重大问题 - 只需过滤或删除第一个标题行并重命名数据列。