Hello! Hey, I'll be working soon with some data that's sent to us in an odd manner (sort of like XML but not quite). I've been wondering about a way to parse it out and attached a PDF with a simple example. Any ideas would be appreciated. I need to get this into an Access database but am not sure of the best way to do it.
Thanks
MishMish3000
Parsing question for odd data set
-
- PlatinumLounger
- Posts: 3691
- Joined: 15 Jul 2010, 14:10
- Location: Milton, TN
Parsing question for odd data set
You do not have the required permissions to view the files attached to this post.
Anne
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Parsing question for odd data set
A little odd that you would need to do this but, hey!
I would consider opening it in a text editor, removing/replacing all the opening tags < with "" (or nothing), then replacing all the closing ones > with a different character - one that won't appear in the file itself, such as a pipe |.
Save the file as a text file and import it (External Data tab, Text file). Don't specify the first row as field names, so that each column will be named Field1, Field2, etc.
You may be able to save the import steps to re-use later.
I tried importing it with just the closing tags > in place, but Access (2010) tries, and fails, to parse it as XML.
Andy.
Added: Mind you, I was assuming that you're just talking about one row of data? Otherwise it becomes a different question. You would need to replace the stuff that tells you that you've reached the end of one record, perhaps <RecordX>... <RecordX> with end-of-line characters.
I would consider opening it in a text editor, removing/replacing all the opening tags < with "" (or nothing), then replacing all the closing ones > with a different character - one that won't appear in the file itself, such as a pipe |.
Save the file as a text file and import it (External Data tab, Text file). Don't specify the first row as field names, so that each column will be named Field1, Field2, etc.
You may be able to save the import steps to re-use later.
I tried importing it with just the closing tags > in place, but Access (2010) tries, and fails, to parse it as XML.
Andy.
Added: Mind you, I was assuming that you're just talking about one row of data? Otherwise it becomes a different question. You would need to replace the stuff that tells you that you've reached the end of one record, perhaps <RecordX>... <RecordX> with end-of-line characters.
Last edited by agibsonsw on 28 Oct 2011, 19:25, edited 1 time in total.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- PlatinumLounger
- Posts: 3691
- Joined: 15 Jul 2010, 14:10
- Location: Milton, TN
Re: Parsing question for odd data set
OK, I'll try that! Sounds interesting. This is a weird, weird data set. :P
Anne
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Parsing question for odd data set
Have you tried importing the actual file as XML? (External data tab of the ribbon, XML file in the Import & Link group)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 3691
- Joined: 15 Jul 2010, 14:10
- Location: Milton, TN
Re: Parsing question for odd data set
No, not yet. In fact, I haven't even gotten an actual copy of the file to play with. I just had my manager show it to me, and started wondering how in the world would I get it into Access! I can try, though. I don't think it's XML... it's in a format called HL7 and is a medical record. It's kinda weird. Thanks for the ideas, though! I'll try to get a copy next week and play with it. Have a great weekend, everyone! :)
Anne
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Parsing question for odd data set
OK, an HL7 file is indeed (very) different from an XML file. Data in an HL7 file are not stored in a table format.
To convert it to one or more Access tables, you will need to have an additional file that describes the structure of the HL7 file. Without that, it is impossible to interpret its meaning.
To convert it to one or more Access tables, you will need to have an additional file that describes the structure of the HL7 file. Without that, it is impossible to interpret its meaning.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 3691
- Joined: 15 Jul 2010, 14:10
- Location: Milton, TN
Re: Parsing question for odd data set
Ah, yes. It's like a definition file or something. The manager talked about that, too. I just got promoted to a new position where I'll be helping to decipher HL7 files, electronic lab reports, things like that. So she was showing me some of the files they're dealing with now. We'd like to be able to import them into database files so we can more easily make reports for the staff to use. Each record seemed to be in one cell of the file, and it has to be parsed out into fields. I'll get a copy of the file and its definition file and play around with it hopefully next week. The official transition takes place on the 13th of Nov. so I have some time to learn. :)
Anne
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Parsing question for odd data set
Conversion will probably require programming. The way it's often done is to parse the HL7 records into a "flat" database table that just contains a bunch of text fields Field1, Field2, Field3 etc., then run a program to move the contents of this "flat" table into the relational structure, using the definition file to interpret the meaning of each field.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Parsing question for odd data set
Came across this site that offers a trial download that can view HL7 and export them as XML.
Whether the XML is in a format that Access can handle would be the next question. If not, then the next step might be to find an XML Schema (that can translate the XML for Access) or an XML Transform (XSLT) that can transform XML files from one format to another; that is, to a format that Access can more readily interpret.
But take what I suggest with a large pinch of salt as it's been ages since I explored XML. Andy.
Whether the XML is in a format that Access can handle would be the next question. If not, then the next step might be to find an XML Schema (that can translate the XML for Access) or an XML Transform (XSLT) that can transform XML files from one format to another; that is, to a format that Access can more readily interpret.
But take what I suggest with a large pinch of salt as it's been ages since I explored XML. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Parsing question for odd data set
Congratulations on your promotion, by the way, MishMish3000!
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 3691
- Joined: 15 Jul 2010, 14:10
- Location: Milton, TN
Re: Parsing question for odd data set
Thank you for the links and for the congratulations! I'm very excited about my new job. Plus the $$$ went up too so that's even better! LOL
Anne