dear friends, I have one text file and I want to import to access table here is text file contains:
<!--:Begin:Chksum:1:-->
<!--:Begin:Msg:2:0:-->
<sample>
<ver>1.1</ver>
<instrinfo>
<p><n>PRDI</n><v>BM800</v></p>
<p><n>FIWV</n><v>2.9.3</v></p>
<p><n>SNO</n><v>26052</v></p>
<p><n>BRND</n><v>M</v></p>
<p><n>IAPL</n><v>H</v></p>
<p><n>LMOF</n><v>1</v></p>
<p><n>PMPM</n><v>25</v></p>
</instrinfo>
<smpinfo>
<p><n>ID</n><v>8798176</v></p>
<smpresults>
<p><n>RBC</n><v>0.00</v><l>0.00</l><h>0.01</h></p>
<p><n>MCV</n><l>0.5</l><h>0.0</h></p>
<p><n>HCT</n><l>0.3</l><h>0.0</h></p>
so I want to import specific part like these words have color red and bold, any one can help me?
AdamDaban:
so I want to import specific part like these words have color red and bold, any one can help me?
That will be very difficult if you don't even explain what tags in your data represent red and bold. I searched for <red>, <b> & <bold> in your text and found none present. I'm astounded that the idea that we may need such information to be able to help you hadn't occurred to you before you posted the question.
this file come from lab test machine usually I will get automatically from it, this is blood test result so I need import this text file into my database, in this case, what should i do?
for example in this sample have SNO and result is 26052 so I need to get a result from each one of them
So, we now have a clear understanding of what words you are looking for and how they are identified.
As the question is far too broad in scope (We have nothing from you as to how you're reading in the file or what format you want the various words returned in.) I will restrict this thread to how to return an array of such words extracted from a string as passed into the function. This will involve identifying any text between either <n> & </n> or <v> & </v>.
Unfortunately I have to run for now but will return at a later date/time in order to offer guidance.
In the mean time I suggest you have a think about what you need from this. Currently it seems your understanding of your own issue seems to be far too unclear. I worry that you won't even know what to do with the help when it comes. This is a position you should not be in.
As far as I can tell, you have a file that is storing relational data in XML format. Where each p node represents a key-value pair with the n node representing the name of the field and the v node represents the value of that column. And where the parent node is the name of a table.
For a more robust solution, I would use an XML parser. For that, you can use the MSXML2.DOMDocument object.
But as NeoPa pointed out, your problem exists at a more basic level. Even if someone were to help you out with a solution, you wouldn't know how to use it. I suggest that you do an Access / VBA tutorial before you attempt a project of this scope.
Rabbit has posted that using an XML parser may be a good idea. I suspect he's correct. However I promised some help to do a specific task so here's the code for that task :
Expand|Select|Wrap|Line Numbers
Public Function GetWords(ByRef strIn As String) As String()
Private Const conChars As String = "nv"
Dim lngIdx As Long, lngPtr As Long, lngLen As Long
NB. I have assumed the data will be in the correct format so have written the code to crash if not. This is preferable to overlooking errors but I'll leave you to insert correct error handling for yourself.
Because of the precise Start and End Tag Structure surrounding the Test Names and associated Test Values, I should be able to come up with Code that displays each Test Name and associated Values. This would only involve a Base Code Segment and a Function Call. Will keep in touch.
AdamDaban:
I don't know how I use your code and how to put in ms access, hope someone can do it I really need it.
I'm afraid that's beyond the scope of this question. It's already got into a bit of a mess as the question was never clearly specified. Please see advice given earlier about using tutorials.
this file come from lab test machine usually I will get automatically from it, this is blood test result so I need import this text file into my database, in this case, what should i do?
I have created a Demo for you based solely on the above quote. I'm still not clear about any specific filtering on the Blood Tests but one step at a time.
Download the Attachment and extract 'both' Files to the same Folder. It makes absolutely no difference what this Folder is, as long as you have the required Permissions on it.
Open Complex Text File.mdb and click on the only Command Button.
The Code, in the Click() Event of this Command Button will:
Open BM-26052-S-20170808-104248-6345-6396.txt and analyze every line in this File.
If a Test is detected based on the parsing of a certain Tag, it will extract the actual Line of Text, the Test Name, and the Test Values.
Each of these three Items will then be added to a Table (tblTestResults) with the Line of Text, the Test Name, and the resultant values in their own Fields. Normally I would never place multiple Values (Test Results) into a single Field, but in this case I feel as though it was warranted.
The last step in the Code execution is the Opening of this Table displaying the parsed results.
You need to be crystal clear as far as any other filtering of Tests, the criteria for these Filters, etc. Right now things are not that clear, at least to me.
I happen to live in Florida (USA) and a Category 5 Hurricane (IRMA) is bearing down on us. If I do not get back to you in a couple of days it will not be for lack of interest but for lack of power (LOL).
Good Luck with this Project.
P.S. - NeoPa, I have an annoying problem with this Demo (cmdTest_Click()) that hopefully you can assist with. The Code works fine, achieving the desired results, as long as On Error Resume Next is in place. The minute I attempt to enforce a normal Error Handler, I received an Invalid Procedure Call or Argument. I have tried every Debugging Technique known to pinpoint the origin of this Error, but to no avail. It really isn't a hugh issue, but more a matter of I can't trace it. In addition, I rarely never use On Error Resume Next and am not particularly fond of it. Thanks in advance for you help in this matter.
I notice the Access file is MDB. If you have a 2010 version that exhibits the same symptoms that would save me having to find somewhere to work in 2003. If not, I can find somewhere, but if you have a 2010 version it would certainly be easier.
Kindly do not refer to me as dear, it is not appreciated, and besides I am a male. That being said, it appears as though you want the Data Transposed from its current format. Will you always be filtering for SNO and RBC?
Sorry for I using this word! Actually, I need to get some of them but I don't want to make you tired when I get Idea from you I will do it another part
ID Date WBC LYM MID GRAN LYM MID GRA RBC HGB
--- --- --- --- --- ---- --- --- -- -- ---
Finally, I think I have a clearer understanding of what you are looking for. Unfortunately, this makes a solution more complicated since the Date component now needs to be extracted and the Unique Test Names now have to be Columns (Fields) in a Table. I need to regroup and figure out how to deal with this, may be a little while.
Sorry, but I cannot proceed any further unless I know the exact meaning/significance of the following Tag Pairs:
Expand|Select|Wrap|Line Numbers
<sample></sample>
<instrinfo></instrinfo>
<smpinfo></smpinfo>
<smpresults></smpresults>
<tparams></tparams>
<hgrams></hgrams>
<hgram></hgram>
<hgdata></hgdata>
I also need to know how the Date/Time Stamps factors into the Data. It appears that all Tests within the <sample></sample> Tags apply to the Date within these Tags also, but I am not sure.
Expand|Select|Wrap|Line Numbers
<n>DATE</n><v>2017-08-08T08:32:43</v></p>
Without this specific information, I'm afraid that I am dead in the water!
P.S. - You need to speak to the individual(s) who are responsible for generating the Text File.
Please check your PMs for the solution to your problem. Actually, I only identify the problem but it's well within your capabilities to find a solution. I wouldn't insult you by trying to offer one.
For the life of me I cannot see how the Data depicted in the Graphic is derived from the Text File. The Graphic is very hazy but the Column Headers appear to be Chemical Symbols supposedly representing the presence of these Elements in the Blood Sample. I see no listing of these Elements within the Text File and, to be perfectly honest, I am lost at this point.
It seems clear you don't have the necessary skills to handle a project like this at this stage. Earlier advice for you (See posts #7 & #8.) indicated you needed better understanding and that a tutorial or two might help. That is still an option, but frankly you communication skills fall too far short to allow you to benefit as much as others from this site. I suspect that's largely due to a language barrier, but it's also, at least partly, due to your failure to respond to all that's written for you. Questions put to you go without an answer. Possibly due to the fact you don't understand the question, but nevertheless a response of some kind is always required.
I suspect my most helpful advice at this stage is to get someone in with experience who can help. Someone that has the whole story that you've struggled to impart clearly here. Employers often misjudge the skill and experience levels required for such projects. It seems you've been dropped in to one that's a bit above your level. If you do manage to convince your boss to get someone in then they may well wish to start with the work that ADezii has already prepared for you. I suspect ADezii has now given up on trying to extract the meaningful information he needs in order to be able to continue to help you.
Best of luck.
PS. Please don't think I'm trying to be rude when I talk about your abilities. We all start somewhere and they are important considerations when trying to answer your question as where you can go next. This may be a learning experience for you - if you want it to be and you have the drive to make it so.
I don't understand why you are thinking like this way and judged me! This website for exchange idea and if you don't like I am there just talk with admin and withdraw me!
AdamDaban:
I don't understand why you are thinking like this way and judged me!
It's quite simple really. I'm not judging you or condemning you. You've asked me for advice and I feel bound to give the most helpful advice I can. Clearly I have to take into consideration whom it is that I'm giving advice to. If I were to give the same advice to you as I would to someone else who is experienced in Access then that would be inappropriate. You would have been unable to understand it or make any use of it.
Of course, I've used your comments and your responses to questions and other posts to allow me to respond in the most helpful manner I can. Bear in mind my comment was not offered out of the blue. It was posted only in response to your request. If it had been my intention to insult you then there was far more scope available (that I did not use). I used only what was needed in order to answer your question.
As with every piece of advice I offer, the person to whom it is directed, you in this case, is always perfectly at liberty to choose how much, if any, they follow that advice.
AdamDaban:
This website for exchange idea and if you don't like I am there just talk with admin and withdraw me!
Technically this site is for Developers and IT professionals. That said we have a large number of amateurs come to ask for help and technical advice. As a general rule you'll find we're happy to work with anyone who wishes to ask a question.
For the record, I am an admin. Not that I would ban you even if I did have a problem with you being here (which clearly I don't). We do ban members from time to time, quite rarely, but only when they continually break our rules (or spammers who go straight away). The worst that could be said about you is that you don't make it at all easy for people to help you. So, I have no problem with you or your presence here. Apart from some frustration trying to assist you, nor does anyone else.
Let me just say, in case it's relevant, that most of us here appreciate that people who generally use languages other than English have a much harder time trying to communicate their questions. We are an exclusively English Language forum. While we understand that, and make allowances where possible, we can only work with what we understand.
There is a list of lessons on the left, start with lesson 1 and work your way through them to get the basics. Normally, I would say you can stop at lesson 52. But for the purposes of your question, you should do all 65 because the ADO and XML lessons will be helpful in solving your original question.
Once you have a foundation, then you will be able to understand and implement the code that ADezii has provided.
I understand that learning a new skill can be slow and laborious. I recommend trying out some tutorials before going for the more complicated stuff. Play with the tutorials and see if you feel this is something you can do, and would like to do. It's always hard to jump right in on a proper and difficult project.
Give yourself time to get up to speed. Enjoy the feeling of creating something and coming up with new ideas to make something happen the way you want it to. It can be real fun if you're suited to it.
Why not see what you can get from some of these tutorial links :
Hi everyone
Do any of you know if this is possible in Access either by using the import
tool or by writing a module in VB:
I have a database containing information for a retail chain which,...
I have a complex xml file, which contains stories within a magazine. The
structure of the xml file is as follows:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<magazine>
<story>...
Hello Experts,
Currently I working on a web application using vs.net with C#.
I require to create an invoice to a text file and print the file. I have
no problem with writing to the text, but...
(Type your message here)
--------------------------------
From: Zephyr .
hey, i got trouble getting integers out of a plain text file.
i dont want to use binary files, just plain text files...
One of Microsoft's pages says it's easier to read and write text files in
..NET 2.0 than 1.1. It doesn't say what exactly was done (to System.IO or
what class?). Can someone tell me?
Greetings,
I have a Access 2007 App and I want to have a Config File. I have several unbound Text Boxes that are in small Date format that will be used as a Filter for several forms. I would like...
I have data in a table in an Access 2000 database that needs to be exported
to a formatted text file. For instance, the first field is an account number
that is formatted in the table as text and...
I am trying to delete multiple lines in a text file using the
following
Private Sub Read_TextFile()
Dim objReader As StreamReader
Dim strfull, strContents, strContentsold, strContentsnew As...
Hi,
I have a complex text file import issue.
The first 13 lines of the file need to be skipped.
Then each of the next 2 lines need to be combined in one record.
the format of one record...
I only need "sample, additional info, reference, analyte, % and Scaling Ref."
see below for example of the text file,
-----------------------------------------------
Method: 1 Metal Mode ...
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...