1-0;5858;658File2;
0-1;;;869File1
Field1;IDFile2;Field;3;Field4;Field5;Field6
5858;658File2;orga8956;tititi;name;Pedro
Field1;IDFile1;Field3;Field4;Field5;Field6;Field7;Field;8;Field9;Field10;Field11;Field12
85;869File1;tttt;name878;ttggg;gfjfhg;gujfh;yyyyy; yyyyy;ttttt;orga8989;tati;Thierr
Relation;Internal ID;ID File 2;ID File1;File2-Field3; File2-Field5; File2-Field6;File1-Field3; File1-Field10;File1-Field12
1-0;5858;658File2; orga8956;name;Pedro;;;;;;;;;;;;
0-1;;;869File1;;;;; name878; orga8989; Thierr
spot-mstt-match.csv
====================
Cardinality;SPoT Internal ID;SPOT ID;MSTT ID
1-0;107828;EMEAS 121214;
1-0;118621;18ETRG4;
1-0;127538;20359, 18G4NFV;
spot.csv
====================
Internal ID;ID;Owning Organization;Organization Code;Name;Leader;Login ID;Project Type;OCP Process;Program Code;Project management framework;Sta
107828;EMEAS 121214;S.Tff.EcoBuilding._EcoB Private;C96;TRAINING project 1;PEDRO;ID26601;NEW;Development;Tff.EcoBuilding.CYPRUS;PMP;Completed;1/
118621;18ETRG4;S.Tff.C4C.PP-C4C;P94;Negative C4C projects buffer;TITI;ID30646;ORGA;N/A;;PMP;Opened;1/1/2013;1/1/1970;1/1/1970;1/1/1970;1/1/1970;
mstt.csv
=====================
SPoT Internal ID;ID;Name;Program code;Project Type;Sharepoint category;Status;Scope;BU ranking;Owning Organization;SPoT Organization Code;Mana
1407;1433861;Advan6 Historic;;NEW;NEW;Completed;Global;0;TINDER.ENERGY.MVS.SPoT Portfolio Management.Offer Dev;E47;MILAN, Sandrine;T10071;C, T
1408;1433862;MATRIX - Project 1;Energy.MVS.MATRIX;NEW;NEW;Completed;Global;0;TINDER.ENERGY.MVS.SPoT Portfolio Management.Offer Dev;E47;LECOQ,
1415;1433869;JARRAH- wave1;Energy.MVS.Jarrah;NEW;NEW;Opened;Global;0;TINDER.ENERGY.MVS.SPoT Portfolio Management.Offer Dev;E47;WIEHE, Clinton;
' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
' Define files to work with
strFile1 = "spot.csv"
strFile2 = "mstt.csv"
strRefFile = "spot-mstt-match.csv"
strFileOut = "out.csv"
strFolder="C:\Scripts-revised\test\folder\matching2"
' Define needed objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
' Set up ADO to access the CSV files and join on reference column
objConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFolder & ";Extended Properties='text'"
strQuery = "SELECT * FROM (" & strRefFile & " RF" & _
" LEFT JOIN " & strFile1 & " F1 ON F1.ID=RF.SPOT_ID)" & _
" LEFT JOIN " & strFile2 & " F2 ON F2.ID=RF.MSTT_ID WHERE RF.Cardinality IS NOT NULL"
objRecordset.Open strQuery, objConnection
' Open output file, write header row
Set objFile = objFSO.OpenTextFile(strFileOut, ForWriting, True)
objFile.WriteLine "Cardinality;InternalID;SPoT Internal ID;SPOT ID;MSTT ID;Owning OrganizationS;Organization CodeS;Owning OrganizationM;SPoT Organization Codem"
' Read all records and reformat before writing to output file
Do Until objRecordset.EOF
objFile.WriteLine _
objRecordset.Fields("RF.Cardinality").Value & ";" & _
objRecordset.Fields("RF.InternalID").Value & ";" & _
objRecordset.Fields("RF.SPoT_Internal_ID").Value & ";" & _
objRecordset.Fields("RF.SPOT_ID").Value & ";" & _
objRecordset.Fields("RF.MSTT_ID").Value & ";" & _
objRecordset.Fields("F1.Owning_Organization").Value & ";" & _
objRecordset.Fields("F1.Organization_Code").Value & ";" & _
objRecordset.Fields("F2.Owning_Organization").Value & ";" & _
objRecordset.Fields("F2.SPoT_Organization_Code").Value
objRecordset.MoveNext
Loop
Format=Delimited(;)
ColNameHeader=True
Col1=Cardinality Text
Col2=SPoT_Internal_ID Text
Col3=SPOT_ID Text
Col4=MSTT_ID Text
[spot.csv]
Format=Delimited(;)
ColNameHeader=True
Col1=Internal_ID Text
Col2=ID Text
Col3=Owning_Organization Text
Col4=Organization_Code Text
Col5=Name Text
Col6=Leader Text
Col7=Login_ID Text
Col8=Project_Type Text
Col9=OCP_Process Text
Col10=Program_Code Text
Col11=Project_management_framework Text
Col12=StatusText
Col13=PMP_OPEN_Date Text
Col14=PMP_SELECT_Date Text
Col15=PMP_DO_Date Text
Col16=PMP_IMPLEMENT_Date Text
Col17=PMP_PRODUCE_Date Text
Col18=PMP_SELL_DateText
Col19=PMP_CLOSE_Date Text
Col20=PMO_1 Text
Col21=Login_ID Text
[mstt.csv]
Format=Delimited(;)
ColNameHeader=True
Col1=SPoT_Internal_ID Text
Col2=ID Text
Col3=Name Text
Col4=Program_code Text
Col5=Project_Type Text
Col6=Sharepoint_category Text
Col7=Status Text
Col8=Scope Text
Col9=BU_ranking Text
Col10=Owning_Organization Text
Col11=SPoT_Organization_Code Text
Col12=Manager_1 Text
Col13=Manager_1_SESA Text
Col14=PMO_1 Text
Col15=PMO_1_SESA Text
Col16=Customer Text
Col17=Start_constraint Text
Col18=Open Text
Col19=Select Text
Col20=Do Text
Col21=Produce Text
Col22=Implement Text
Col23=Sell Text
Col24=Close Text
Col25=Solution_code Text
Col26=OCP_Process Text
Col27=Old_Project_Id Text
Cardinality;SPoT_Internal_ID;SPOT_ID;MSTT_ID[\code]
spot.csv
[code]Internal ID;ID;Owning Organization;Organization Code;Name;Leader;Login ID;Project Type;OCP Process;Program Code;Project management framework;Status;PMP OPEN Date;PMP SELECT Date;PMP DO Date;PMP IMPLEMENT Date;PMP PRODUCE Date;PM
SPoT_Internal_ID;ID;Name;Program_code;Project_Type;Sharepoint_category;Status;Scope;BU_ranking;Owning_Organization;SPoT_Organization_Code;Manager_1;Manager_1_SESA;PMO_1;PMO_1_SESA;Customer;Start_constraint;Open;Select;Do;Produce;Implement;Sell;Close;Solution_code;OCP_Process;Old_Project_Id
Your script works perfectly. However I am trying to adapt it to other files and I am not able to launch properly I don't know if there is an specific syntax for the field. Could you please help me with this.
Attached you will find the reference files.
Thank you in advance for your help.