读取包含反斜杠的文件时出错
我有一个csv文件内部行字符串包括""one_answers" ";在字符串内部如果我使用pandas read_csv,即使使用正确的编码,也会出现错误。即使有各种编码,我得到不同的错误,但没有一个工作。只有当我用另一个字符替换反斜杠时,它才能工作。
任何想法?
亲切的问候,
import pandas as pd
df = pd.DataFrame()
df = pd.read_csv(r'C:testfile.csv',encoding="unicode_escape")
print(df.head())
测试文件:
Source chart;Chart element;Element comment;Block type;Destination chart;Chart element;Element comment;Block type;
"@CPU_RT";"@CPU_RT.CPU_RT_DATA";"";"CPU_RT";"@(1)";"AS_1.CPU_RT_DATA";"";"OB_BEGIN";
"@(1)";"AS_1.CPU_DIAG";"";"OB_BEGIN";"@(2)";"AS_2.CPU_DIAG";"";"OB_END";
"@(1)";"AS_1.EN_SUB0";"Enable Subnet 0";"OB_BEGIN";"@(3)";"CPU_410-5H_1.EN";"";"SUBNET";
"@(1)";"AS_1.CPU_DIAG";"";"OB_BEGIN";"@(3)";"CPU_410-5H_1.CPU_DIAG";"";"SUBNET";
"@(1)";"AS_1.CPU_OB_5X";"";"OB_BEGIN";"@(3)";"CPU_410-5H_1.CPU_OB_5X";"";"SUBNET";
"@(1)";"AS_1.SZL_71";"";"OB_BEGIN";"@(3)";"CPU_410-5H_1.SZL_71";"";"SUBNET";
"@(5)";"UR2ALU_1.OUT";"";"AND";"@(4)";"UR2ALU_1.EN";"";"RACK";
"@(1)";"AS_1.CPU_DIAG";"";"OB_BEGIN";"@(4)";"UR2ALU_1.CPU_DIAG";"";"RACK";
"@(3)";"CPU_410-5H_1.SUB_DIAG";"";"SUBNET";"@(4)";"UR2ALU_1.SUB_DIAG";"";"RACK";
"@(3)";"CPU_410-5H_1.EN_R0";"Enable Rack 0";"SUBNET";"@(5)";"UR2ALU_1.IN1";"";"AND";
"@(1)";"AS_1.EN_SUB0";"Enable Subnet 0";"OB_BEGIN";"@(5)";"UR2ALU_1.IN2";"";"AND";
"@(1)";"AS_1.CPU_DIAG";"";"OB_BEGIN";"@(6)";"CP_443-1_1.CPU_DIAG";"";"MOD_CENTRAL";
"@(4)";"UR2ALU_1.RAC_DIAG";"";"RACK";"@(6)";"CP_443-1_1.RAC_DIAG";"";"MOD_CENTRAL";
"@(7)";"PS_405_10A_1.OUT";"";"AND";"@(6)";"PS_405_10A_1.EN";"";"PS";
"@(1)";"AS_1.CPU_DIAG";"";"OB_BEGIN";"@(6)";"PS_405_10A_1.CPU_DIAG";"";"PS";
"@(4)";"UR2ALU_1.RAC_DIAG";"";"RACK";"@(6)";"PS_405_10A_1.RAC_DIAG";"";"PS";
"@(5)";"UR2ALU_1.OUT";"";"AND";"@(7)";"PS_405_10A_1.IN1";"";"AND";
"@(4)";"UR2ALU_1.EN_M0";"Enable MODUL 0";"RACK";"@(7)";"PS_405_10A_1.IN2";"";"AND";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.AutAct";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_AutAct";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.Cmd1Act";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_Cmd1Act";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.Cmd2Act";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_Cmd2Act";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.Cmd3Act";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_Cmd3Act";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.Cmd4Act";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_Cmd4Act";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.Cmd5Act";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_Cmd5Act";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1Test_CCM\Pomp_CCM";"CCM.LockAct";"";"CCM";"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.CCM_LockAct";"";"Test_CCM_EMT";
"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CMD_Q";"Active Setpoint";"CCM_EPHT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CMD_AI";"Actual Value Input";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.QAUTMAN";"Current operating mode";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_QAUTMAN";"Current operating mode";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.IDLE";""Idle" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_IDLE";""Idle" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.STARTING";""Starting" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_STARTING";""Starting" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.RUN";""Run" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_RUN";""Run" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.READY_TC";""Ready to complete" state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_READY_TC";""Ready to complete" state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.COMPLETING";""Completing" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_COMPLETING";""Completing" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.ERROR_COMPLETING";""Error completing" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_ERROR_COMPLETING";""Error completing" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.COMPLETED";""Completed" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_COMPLETED";""Completed" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.HOLDING";""Holding" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_HOLDING";""Holding" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.HELD";""Held" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_HELD";""Held" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.RESUMING";""Resuming" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_RESUMING";""Resuming" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.ERROR";""Error" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_ERROR";""Error" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.HELD_ERROR";""Held error" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_HELD_ERROR";""Held error" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.RESU_ERROR";""Resuming error" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_RESU_ERROR";""Resuming error" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.ABORTING";""Aborting" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_ABORTING";""Aborting" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.ABORTED";""Aborted" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_ABORTED";""Aborted" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.STOPPING";""Stopping" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_STOPPING";""Stopping" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.STOPPED";""Stopped" operating state";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_STOPPED";""Stopped" operating state";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.BUSY";"Status "Busy" (=neither "Idle" nor "Completed" nor "Aborted" nor "Stopped")";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_BUSY";"Status "Busy" (=neither "Idle" nor "Completed" nor "Aborted" nor "Stopped")";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.ERRG";"Collective error(QEXT_ERR|OP_ERR|LI_ERR|EXEC_ERR)";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_ERRG";"Collective error(QEXT_ERR|OP_ERR|LI_ERR|EXEC_ERR)";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.QDIS_START";"Disable "Start"";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_QDIS_START";"Disable "Start"";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.QCONT_T_ERR";"Max. run time for "Continuous mode" exceeded";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_QCONT_T_ERR";"Max. run time for "Continuous mode" exceeded";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.POSINO";"Position text number";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_POSINO";"Position text number";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.OPTIPNO";"Information text number for operator";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_OPTIPNO";"Information text number for operator";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.QCS";"Current control strategy";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_QCS";"Current control strategy";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.Command_AO";"Actual Value Output";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_Command_AO";"Actual Value Output";"CCM_EPHT";
"KitchenStove_1Pot_1Test_CCM\CCM1_EMT";"Test_CCM_EMT.Command_ERR";"Setpoint Input Error";"Test_CCM_EMT";"KitchenStove_1Pot_1CCM\CCM1_EPHT";"CCM_EPHT.CCM_EMT_Command_ERR";"Setpoint Input Error";"CCM_EPHT";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.MotRevL_FwdAut";"1=Start: Forward Start Command in Auto Mode";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.FwdAut";"1=Start: Forward Start Command in Auto Mode";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.MotRevL_StopAut";"1=Stop: Stop Command in Auto Mode";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.StopAut";"1=Stop: Stop Command in Auto Mode";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.MotRevL_RevAut";"1=Start: Reverse Start Command in Auto Mode";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.RevAut";"1=Start: Reverse Start Command in Auto Mode";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.MotRevL_ModLiOp";"1=Link/Auto,0=Manual: Input to Auto/Manual Commands";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.ModLiOp";"1=Link/Auto,0=Manual: Input to Auto/Manual Commands";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.MotRevL_AutModLi";"1=Auto Mode: Auto Mode by Linked or SFC";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.AutModLi";"1=Auto Mode: Auto Mode by Linked or SFC";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.MotRevL_RstLi";"Linked Reset Signal";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.RstLi";"Linked Reset Signal";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.QBA_EN";"BATCH enable";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.BatchEn";"Enable Remote Operation of Controller by Batch Recipe";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.QBA_ID";"BATCH charge number";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.BatchID";"Current Batch ID (number)";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.QBA_NA";"BATCH charge name";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.BatchName";"Current Batch Name";"MotRevL";
"KitchenViewport_1Desk_1Turn\Desk_1_Turn";"De1_Turn.QSTEP_NO";"BATCH step number 32Bit";"Turn";"KitchenViewport_1Desk_1TurnMot_Turn\De1_Mot_Turn";"De1_Mot_Turn.StepNo";"Batch Step Number";"MotRevL";
"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.Closed";"1=Valve is Closed";"VlvL";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"3.In1";"Input 1";"Or04";
"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.Closing";"1=Valve is Closing";"VlvL";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"3.In2";"Input 2";"Or04";
"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.Opened";"1=Valve is Open";"VlvL";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"4.In1";"Input 1";"Or04";
"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.Opening";"1=Valve is Opening";"VlvL";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"4.In2";"Input 2";"Or04";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.VlvL_OpenAut";"1=Open: Open Command in Auto Mode";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.OpenAut";"1=Open: Open Command in Auto Mode";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.VlvL_CloseAut";"1=Close: Close Command in Auto Mode";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.CloseAut";"1=Close: Close Command in Auto Mode";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.VlvL_ModLiOp";"1=Link/Auto,0=Manual: Input to auto/manual commands";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.ModLiOp";"1=Link/Auto,0=Manual: Input to auto/manual commands";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.VlvL_AutModLi";"1=Auto mode: Auto mode by linked or SFC";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.AutModLi";"1=Auto mode: Auto mode by linked or SFC";"VlvL";
"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"4.Out";"Output";"Or04";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.FbkOpen";"1=Open: Feedback of Valve Opened";"VlvL";
"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"3.Out";"Output";"Or04";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.FbkClose";"1=Close: Feedback of Valve Closed";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.VlvL_RstLi";"Linked reset signal";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.RstLi";"Linked reset signal";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.QBA_EN";"BATCH enable";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.BatchEn";"Enable remote operation of controller by Batch recipe";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.QBA_ID";"BATCH charge number";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.BatchID";"Current Batch ID (number)";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.QBA_NA";"BATCH charge name";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.BatchName";"Current Batch name";"VlvL";
"KitchenViewport_1Desk_1Drain\Desk_1_Drain";"De1_Drain.QSTEP_NO";"BATCH step number 32Bit";"Drain";"KitchenViewport_1Desk_1DrainVal_Drain\De1_Val_Drain";"De1_Val_Drain.StepNo";"Batch step number";"VlvL";
"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.Closed";"1=Valve is Closed";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"3.In1";"Input 1";"Or04";
"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.Closing";"1=Valve is Closing";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"3.In2";"Input 2";"Or04";
"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.Opened";"1=Valve is Open";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"4.In1";"Input 1";"Or04";
"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.Opening";"1=Valve is Opening";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"4.In2";"Input 2";"Or04";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Oel_OpenAut";"1=Open: Open Command in Auto Mode";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.OpenAut";"1=Open: Open Command in Auto Mode";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Oel_CloseAut";"1=Close: Close Command in Auto Mode";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.CloseAut";"1=Close: Close Command in Auto Mode";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Oel_ModLiOp";"1=Link/Auto,0=Manual: Input to auto/manual commands";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.ModLiOp";"1=Link/Auto,0=Manual: Input to auto/manual commands";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Oel_AutModLi";"1=Auto mode: Auto mode by linked or SFC";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.AutModLi";"1=Auto mode: Auto mode by linked or SFC";"VlvL";
"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"4.Out";"Output";"Or04";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.FbkOpen";"1=Open: Feedback of Valve Opened";"VlvL";
"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"3.Out";"Output";"Or04";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.FbkClose";"1=Close: Feedback of Valve Closed";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Oel_RstLi";"Linked reset signal";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.RstLi";"Linked reset signal";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.QBA_EN";"BATCH enable";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.BatchEn";"Enable remote operation of controller by Batch recipe";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.QBA_ID";"BATCH charge number";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.BatchID";"Current Batch ID (number)";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.QBA_NA";"BATCH charge name";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.BatchName";"Current Batch name";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.QSTEP_NO";"BATCH step number 32Bit";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Oil\De1_Val_Oil";"De1_Val_Oil.StepNo";"Batch step number";"VlvL";
"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"De1_Val_Pepper.Closed";"1=Valve is Closed";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"3.In1";"Input 1";"Or04";
"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"De1_Val_Pepper.Closing";"1=Valve is Closing";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"3.In2";"Input 2";"Or04";
"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"De1_Val_Pepper.Opened";"1=Valve is Open";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"4.In1";"Input 1";"Or04";
"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"De1_Val_Pepper.Opening";"1=Valve is Opening";"VlvL";"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"4.In2";"Input 2";"Or04";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Pepper_OpenAut";"1=Open: Open Command in Auto Mode";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"De1_Val_Pepper.OpenAut";"1=Open: Open Command in Auto Mode";"VlvL";
"KitchenViewport_1Desk_1Add_Ingredients\Desk_1_Add_Ingredie";"De1_add_Ingredie.Pepper_CloseAut";"1=Close: Close Command in Auto Mode";"Add_Ingredient";"KitchenViewport_1Desk_1Add_IngredientsVal_Pepper\De1_Val_Pepper";"De1_Val_Pepper.CloseAut";"1=Close: Close Command in Auto Mode";"VlvL";
我认为主要问题是你的文件不是CSV文件-一个">逗号分隔的文件",它是一个CSV文件- ">分号分隔文件"因此,如果告诉pandas csv_reader用分号分隔字段,结果应该会好得多。
import pandas as pd
df = pd.read_csv("test2.csv", delimiter=';')
print(df.head())
另外,顺便说一下,你在第58行代码中出错的原因是因为这是第一行中有逗号的行-所有其他行都被读取为"一个字段"。基于逗号分隔的值,但这一行被分割成多个字段,然后您有太多字段。
在另一个文件中,我得到了一个"UnicodeDecodeError: 'utf-8'编解码器无法解码位置157936中的字节0xb3:无效的开始字节"错误。解决方案是将文件编码cp1252添加到read_csv命令
中import pandas as pd
df = pd.DataFrame()
file_encoding = 'cp1252'
df = pd.read_csv(r'C:Testmaptestfilelarge.csv', delimiter=';',encoding = file_encoding)