我的数据包含一个字段,其中值由','分隔。正常程序可能是使用文本限定符,例如"转储为csv格式时允许数据正确显示。但是,读入此csv文件的代码无法使用此类文件,除非我先打开文件并重新保存。这会导致二进制数据发生变化。
示例:
手动预存文件。
"value1","value2","value3_A,value3_B"etc...
打开/重新保存文件后:
value1, value2, value3, "value4_A,value4_B"etc.....
如何逐步获得第二个结果。我不确定excel正在做什么,但我的猜测是它在特定的单元格上使用文本限定符。
问题是,如果我使用方法#1执行此操作,则根据开发人员编写的脚本,该文件是不可读的。 (目前我们无法解决这个问题),所以我需要解决这个问题。
任何建议,谢谢。
更新 文件的二进制文件:
预先重新保存(使用txt限定符(")将SSIS原始输出发送到.CSV):
"id","type","creation class","index","label","manufacturer","model number","part number","attributes","orientation","internal routes","x","y","width","height","connector"
"10971545","0ccbb2a8-2bea-4038-ab83-c9cced273b61","-225094789","0","Torrance ZENITH - ZTG TRANSFER SWITCH - Panel","Unknown","Torrance ZENITH - ZTG TRANSFER SWITCH - Panel","","M&E=Yes~Input Beaker Rating (A)=100~Input Frequency (Hz)=60~Input Phase=Three~Input Rating (A)=~Input Rating (kVA)=36.0267~Input Voltage (VAC)=208~Output Voltage (VAC)=208~Power Factor=0.8~Rating (A)=100~Rating (kVA)=36~Rating (W)=16640~Rating Per Phase(A)=~Voltage (VDC)=~Weight (kg)=~Image Files=~","0","","0","0","49","49",""
"","4000","-225094829","1003","PowerOut 01","","","","Phase=1P~Voltage (VAC)=208~Rating (A)=100~Voltage (VDC)=~","1",",1001,1002,","-1","3","50","46","PowerCable 20mm (AC)"
"","4000","-225094830","1001","PowerIn 01","","","","Phase=1P~Voltage (VAC)=208~Rating (A)=40~Voltage (VDC)=~","1","","0","-43","50","46","PowerCable 20mm (AC)"
"","4000","-225094830","1002","PowerIn 02","","","","Phase=1P~Voltage (VAC)=208~Rating (A)=40~Voltage (VDC)=~","1","","0","3","50","46","PowerCable 20mm (AC)"
发布ReSave(在EXcel中打开CSV(Ctrl + S)关闭文件>检查二进制文件:
id,type,creation class,index,label,manufacturer,model number,part number,attributes,orientation,internal routes,x,y,width,height,connector
10971545,0ccbb2a8-2bea-4038-ab83-c9cced273b61,-225094789,0,Torrance ZENITH - ZTG TRANSFER SWITCH - Panel,Unknown,Torrance ZENITH - ZTG TRANSFER SWITCH - Panel,,M&E=Yes~Input Beaker Rating (A)=100~Input Frequency (Hz)=60~Input Phase=Three~Input Rating (A)=~Input Rating (kVA)=36.0267~Input Voltage (VAC)=208~Output Voltage (VAC)=208~Power Factor=0.8~Rating (A)=100~Rating (kVA)=36~Rating (W)=16640~Rating Per Phase(A)=~Voltage (VDC)=~Weight (kg)=~Image Files=~,0,,0,0,49,49,
,4000,-225094829,1003,PowerOut 01,,,,Phase=1P~Voltage (VAC)=208~Rating (A)=100~Voltage (VDC)=~,1,",1001,1002,",-1,3,50,46,PowerCable 20mm (AC)
,4000,-225094830,1001,PowerIn 01,,,,Phase=1P~Voltage (VAC)=208~Rating (A)=40~Voltage (VDC)=~,1,,0,-43,50,46,PowerCable 20mm (AC)
,4000,-225094830,1002,PowerIn 02,,,,Phase=1P~Voltage (VAC)=208~Rating (A)=40~Voltage (VDC)=~,1,,0,3,50,46,PowerCable 20mm (AC)
您可以在结果2中看到,列内部路由具有文本限定字段,而文件的其余部分不是' t",1001,1002," 在结果1中,整个输出是文本限定的,不起作用。
试图理解为什么以及如何以前瞻性的方式获得相同的结果。
当前解决方案(Hacky): 输出文件是使用阶段表中的视图创建的,我为此处理和格式化数据。我刚刚附上了#34;到了场地的前端和末端。这给了我想要的输出。只是觉得hacky,谁知道将来如何传递数据。仍然希望了解没有太多vb或C#的动态解决方案,因为这会增加我想避免的复杂性。
答案 0 :(得分:1)
您可以使用脚本任务来编写输出。这将允许您使用VB或C#语法自己控制格式。更多详情:https://docs.microsoft.com/en-us/sql/integration-services/extending-packages-scripting-data-flow-script-component-types/creating-a-destination-with-the-script-component
答案 1 :(得分:0)
当前解决方案(Hacky):输出文件是使用阶段表中的视图创建的,我根据这些视图处理和格式化数据。我刚刚附上了#34;到了场地的前端和末端。这给了我想要的输出。只是觉得hacky,谁知道将来如何传递数据。仍然希望了解没有太多vb或C#的动态解决方案,因为这会增加我想避免的复杂性。