Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parsing a file that's not quite comma-delimited
Message
De
11/07/2007 11:13:08
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/07/2007 10:55:42
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01238841
Message ID:
01239298
Vues:
16
This message has been marked as a message which has helped to the initial question of the thread.
Jay,
Here is a rough parser as I promised:
text TO m.lcSample noshow
MSH|^~\&|Medinotes|CP|External||20070705154008||DFT^P03|468D4AD320F3|P|2.4|||AL|||
EVN|P03|20070705154008|20070705154008
PID|1|11384|468AE48A7926||Johengen^Jay||20051108000000||||||||||||
PV1|1|O|Ambulatory Surgery Center^^^^^^^^Ambulatory Surgery Center||||^Cardio^Full|||||||||||||||||||||||||||||||||||||20070705154008||||||
ORC|SN|
FT1|1|||20070705154008||CG||||||||||^^^Ambulatory Surgery Center|||250.00^Diabetes Mellitus Without Mention Of Complication, Type II Or Unspecified Type, Not Stated As Uncontrolled^I9|^Cardio^Full|||||99212^Office Or Other Outpatient Visit For The Evaluation And Management Of An Established Patient, Which Requires At Least Two Of These Three Key Components: A Problem Focused History; A Problem Focused Examination; Straightforward Medical Decision Making. Counseling And/Or Coordination Of Care With Other Providers Or Agencies Are Provided Consistent With The Nature Of The Problem(s) And The Patient's And/Or Family's Needs. Usually, The Presenting Problem(s) Are Self Limited Or Minor. Physicians Typically Spend 10 Minutes Face-To-Face With The Patient And/Or Family.^C4|
DG1|1||250.00^Diabetes Mellitus Without Mention Of Complication, Type II Or Unspecified Type, Not Stated As Uncontrolled^I9|||F
ENDTEXT

FOR ix=1 TO alines(laLines,m.lcSample) STEP 7
	* One block of tables is 7
	FOR jx = 0 TO 6
		STORE LineToObject(laLines[m.ix+m.jx]) TO ('loObj'+LTRIM(STR(m.jx+1)))
	ENDFOR
	* Here insert into relevant tables
endfor


procedure LineToObject(tcLine)
  local loRecord,ix
  loRecord = createobject('Empty')
  addproperty(loRecord, 'TableName', getwordnum( m.tcLine,1,'|'))
  for ix=1 to occurs('|',m.tcLine)
    addproperty(loRecord, ;
      'field'+padl(m.ix,3,'0'), ;
      strextract(m.tcLine,'|','|',m.ix,2))
  endfor
  return loRecord
endproc
If you create specialized LineToObject methods that match with field namings of target tables then you'd directly do an insert into in those methods. The one I wrote is a generic parser.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform