Generate edi 837p file from csv file

Please let me know the code file or snippet to Generate edi 837p file from csv file
Programming language used can be vba , php etc
My csv file is single sheet text csv file with columns having info like

Insurance Company Name Insurance Company Name 2 Insurance Company Address 1 Insurance Company Address 2 1-InsuredPlanName 1a-InsuredIDNo 2-PatientName 3-PatientDOB 3-PatientGender 4-InsuredName 5-PatientAddress 5-PatientCity 5-PatientState 5-PatientZip 5-PatientPhone 6-PatientRel 7-InsuredAddr 7-InsAddCity 7-InsAddState 7-InsAddZip 7-InsAddPhone 8-MaritalStatus 8-Employed? 9-InsuredName2 9a-InsuredGroupNo2 9b-NUCC Use 9b-Insured2DOB 9b-Insured2Gender 9b-ReservedForNUCCuse 9c-ReservedForNUCCuse 9c-EmployerName 9d-InsuredPlanName2 10a-CondEmployment 10b-CondAutoAccident 10c-CondOtherAccident 10b2-AccidentState 10d-LocalUse 11-InsuredGroupNo 11a-InsuredDOB 11a-InsuredGender 11b-OhterClaimID 11b-EmployerName 11c-InsuredPlanName 11d-OtherHealthPlan 12-PatientSign 12-Date 13-AuthSign 14-DateOfCondition 15-OtherDate 15-OtherDateInd 15-FirstDateOfCondition 16-DateFromNoWork 16-DateToNoWork 17-ReferringPhysician 17-ReferringPhysicianInd 17a-PhysicianNo 17b-ReferNPI 18-DateFromHosp 18-DateToHosp 19-LocalUse 20-OutsideLab 20-Charges 21-1-Diagnosis 21-2-Diagnosis 21-3-Diagnosis 21-4-Diagnosis 21-IcdInd-9 or 10 Indicator 21-a-Diagnosis 21-b-Diagnosis 21-c-Diagnosis 21-d-Diagnosis 21-e-Diagnosis 21-f-Diagnosis 21-g-Diagnosis 21-h-Diagnosis 21-i-Diagnosis 21-j-Diagnosis 21-k-Diagnosis 21-l-Diagnosis 22-MedicaidResubmissionCode 22-MedicaidResubmissionRefNo 23-PriorAuth 24-1-supplemental 24-1-i-Qualifier 24-1-j-ProvLegacyNo 24-1-a-DOSFrom 24-1-a-DOSto 24-1-b-Place 24-1-c-emg 24-1-d-CPT 24-1-d-Modifier 24-1-e-code 24-1-f-Charges 24-1-g-Units 24-1-h-epsdt 24-1-j-ProvNPI 24-2-supplemental 24-2-i-Qualifier 24-2-j-ProvLegacyNo 24-2-a-DOSfrom 24-2-a-DOSto 24-2-b-Place 24-2-c-emg 24-2-d-CPT 24-2-d-Modifier 24-2-e-code 24-2-f-Charges 24-2-g-Units 24-2-h-epsdt 24-2-j-ProvNPI 24-3-supplemental 24-3-i-Qualifier 24-3-j-ProvLegacyNo 24-3-a-DOSfrom 24-3-a-DOSto 24-3-b-Place 24-3-c-emg 24-3-d-CPT 24-3-d-Modifier 24-3-e-code 24-3-f-Charges 24-3-g-Units 24-3-h-epsdt 24-3-j-ProvNPI 24-4-supplemental 24-4-i-Qualifier 24-4-j-ProvLegacyNo 24-4-a-DOSfrom 24-4-a-DOSto 24-4-b-Place 24-4-c-emg 24-4-d-CPT 24-4-d-Modifier 24-4-e-code 24-4-f-Charges 24-4-g-Units 24-4-h-epsdt 24-4-j-ProvNPI 24-5-supplemental 24-5-i-Qualifier 24-5-j-ProvLegacyNo 24-5-a-DOSfrom 24-5-a-DOSto 24-5-b-Place 24-5-c-emg 24-5-d-CPT 24-5-d-Modifier 24-5-e-code 24-5-f-Charges 24-5-g-Units 24-5-h-epsdt 24-5-j-ProvNPI 24-6-supplemental 24-6-i-Qualifier 24-6-j-ProvLegacyNo 24-6-a-DOSfrom 24-6-a-DOSto 24-6-b-Place 24-6-c-emg 24-6-d-CPT 24-6-d-Modifier 24-6-e-code 24-6-f-Charges 24-6-g-Units 24-6-h-epsdt 24-6-j-ProvNPI 25-TaxID 25-SSN/EIN 26-PatientAcctNo 27-AcceptAssign 28-TotalCharge 30-BalanceDue 31-Date 32-FacilityName 32-Facilitystreet 32-FacilityAddr 33-BillingName 33-Billingstreet 33-BillingAddr 33-BillingPhone 32-a-NPI 32-b-GrpLegacyNo 33-a-NPI 33-b-GrpLegacyNo 24-1-srvcomment 24-2-srvcomment 24-3-srvcomment 24-4-srvcomment 24-5-srvcomment 24-6-srvcomment 29-AmountPaid 30-ReservedForNUCCuse 31-PHYSICIANMIDDLE 31-PHYSICIANFIRST 31-PHYSICIANLAST 31-PHYSICIANCREDENTIAL