Modules & VBA :: Unwrap Text For Import And Reformat As Table
May 26, 2015
Getting close, but missing a step or two. Have a series of text files that need to be cleaned up and reformatted. The issue is two fold. Need to remove hard return wrapping so that each line is complete and then format to a table structure. I built code that imports fine if no wrapping. I tried this link and seemed to work, except in my implementation it is putting in delimiters, so that if a row of data has a comma, it treats that as a separate field rather than a single field. I thought that fixed width would mean that it ignores potential delimiter characters.
[URL]
The other problem is with the logic so that sometimes in is concatenating a new line to the old line. There may be exceptions due to typos and older files that used a tab rather than space, but seems in general like the indication of a wrap termination is that a new record will begin with either a number period and space or a letter (a, b, c, d only) a period and a space. The next part of building the table is tricky because the question needs to be repeated for each response as shown below in phase 2.
Example from plain text file (xxx.txt):
1. This is line one sentence
a. response a
b. response b
c. response c
d. response d
2. This is line two sentence
and it wraps
a. response a
b. response b
c. response c is
also wrapping
d. response d
----------------------------------
Phase 1 result should be:
-----------------------------------
1. This is line one sentence
a. response a
b. response b
c. response c
d. response d
2. This is line two sentence and it wraps
a. response a
b. response b
c. response c is also wrapping
d. response d
----------------------------------
Phase 2 result should be an access table with several cols:
-----------------------------------
Code:
QNO Question Response Answer
1 This is line one sentence a response a
1 This is line one sentence b response b
1 This is line one sentence c response c
1 This is line one sentence d response d
2 This is line two sentence and it wraps a response a
2 This is line two sentence and it wraps b response b
2 This is line two sentence and it wraps c response c is also wrapping
2 This is line two sentence and it wraps d response d
Here is the code that I'm trying to use for unwrapping.
Code:
Private Sub btnUnwrapText_Click()
'Create a new text file that has removed the wrapped text
'assumes that wrapping only occurs on second line. If
'wrapping exceeds two lines, code won't work. Haven't had
[Code].....
View Replies
ADVERTISEMENT
Mar 14, 2012
How to remove unwrap text after exporting report from Access to Excel?
View 11 Replies
View Related
Apr 2, 2015
I'm trying to import a pipe delimited text file into a table. I can import the entire table using the following code, but I only get one column of data (the entire data set in one column). If possible I would like to import with the columns defined or if not possible use some code for a function similar to text to columns.
Code:
DoCmd.TransferText acImportDelim, , "tblTest", "C:Work2015PPVMasterData.txt"
View 4 Replies
View Related
Jul 19, 2014
They are receiving e-mail with some data that they want to transfer to access database to track. The one think they can do is copy past, copy paste. That is a lot of data to copy and paste. The date looks like this format
Field1
Text1
Field2
Text2 (text2 can be more than 255 char)
Field3
Text3 (text3 can be more than 255 char)
Field4
Text4
Field1
Text1
Field2
Text2 (text2 can be more than 255 char)
Field3
Text3 (text3 can be more than 255 char)
Field4
Text4
and so on.. It can be 50 records
I am thinking they can copy this to the text file. Then the code form Access grabs the text file and imports to access table with format below.
Field1 Fied2 Field3 Field4
Text1 Text2 Text3 Text4
View 14 Replies
View Related
Nov 6, 2014
I have a text file that details every single incident that happened in the system. This means that it is extremely messy and non-comprehensible to a normal person due to the use of codewords and all.
Is it possible to scan through the document and insert the data into access, such that the different keywords are put as seperate events?
Ps, the number of characters between each event and data may not always be the same, so seperating them by that is not the way to do it. However, when I open the file in notepad++, I can confirm that each event is 6 lines.
E.g. Line 1 = Event timestamp, Line 2 = Event Name, Line 3 = Acknowledged or not, Line 4 = Acknowledged by who, Line 5 = Event Details, Line 6 = Application Owner.
Basically, the 6 lines are the 6 columns that I would need in my table. So, is it possible to separate out and read every 6 lines of data in the text file?
View 14 Replies
View Related
Aug 19, 2013
We have a function that will allow a user to navigate to a text file and import it to a database. I've been asked to make it import ALL the text files from all sub-directories in the directory IF they've never been imported before (based on FileName and LastModifiedDate). I've set up a table to track what's getting imported (tbl_ImportHistory). I'm thinking what I need to do is use the previous coder's GetFileName function in a recursive loop removing the navigation request and adding the comparison and then, if it imports the file, the name and date need to be added to the tbl_ImportHistory table. But I'm completely unsure of how to do it.
I'm posting the GetFileName function below. I believe once I've got it modified the rest of the code can be left intact as it just parse's and loads whatever file is selected in the GetFileName function.
<code>
Function GetFileName() As String
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = False
Dim vrtSelectedItem As Variant
[code]....
View 5 Replies
View Related
Oct 18, 2014
How to read data in file (attached) and import data by reading certain amount of characters in a line like A02 and read 30 to 40 characters which has the Name of a passenger and may 20th to 25 has the name of an Airline. Import these data into a table with pre-assigned columns.
View 11 Replies
View Related
Sep 10, 2013
I have a VBA code to import mail from Lotus Notes into Access. The database user is able to read his email inside Access, similar to any email program.
Unfortunately, when I use the GetItemValue (lotusscript) method to read the body of the email message, Notes will render the Rich Text information as Plain Text, and I end up with no formatting information (bold letters, underline, text color, etc.)
How to import messages from Notes to Access and keep the text formatting? I am storing the data in a Rich Text Memo field in a table. I have found code to write HTML (MIME) messages, but not to import them into Access.
View 2 Replies
View Related
Jul 19, 2005
Hi, I'm trying to import a text file (just for a test at the moment) with the fields seperated by |'s.
The table I'm trying to import to has the fields -
ID, First Name, Last Name, Gender.
The ID is an autonumber though so what can I put there in the text file because I'm getting an error? :confused:
View 3 Replies
View Related
Aug 2, 2013
I'm trying to import a text file with 273 fields into two tables. I've been able to do this with the code I found on an old thread and I'm now trying to accomplish everything with one step. The file I'm importing is tab delimited text file. With this current code I'm only able to populate the first record in the table and then I get error message. (Run-time error '3265') (Item cannot be found in the collection corresponding to the reqested name or ordinal).
Code:
Public Sub ImportTextFile()
' to use the ADODB.Recordset, be sure you have a reference set to ADO
Dim rst As ADODb.Recordset
Dim rst2 As ADODb.Recordset
Dim strFile As String
Dim strInput As String
Dim varSplit As Variant
Dim intCount As Integer
[code]...
View 4 Replies
View Related
Dec 18, 2004
Hello everyone!
Here is my problem:
I have an Access database that contains a table with three columns (A & B & C). Field A is for code values and field B is for the value for that particular code. Field C holds the case number. I have a folder that contains the information for over 5000 case numbers. Each case number needs to be placed inside of the table. Considering there are 5000 case numbers, I dont want to use the import wizard 5000 times.
Furthermore, the text file only has two columns (for A and B).
I am trying to create a VBA that will append rows to the table by going into each file and placing the information into the table. The first row for each file contains the case number. So when the VBA runs, it should open the text file get the case number from the first row (field B on the text file) and place that in the case number field of the table for the entire file; and then repeat this action for all of the files in the entire folder.
Any help that can be provided will be greatly appreciated.
Thanks.
View 13 Replies
View Related
Aug 22, 2014
I have a form which i use for a user to select an excel file they want to import and then click a cmd button to import the file into a table which works fine, however i want to append a date into a date field from an unbound txtbx before the file is imported so it will look something like;
id;date;excel info;excel info;excel info.
View 7 Replies
View Related
Aug 28, 2014
Is it possible to have a command button on a form to run the Text File Import Into a Table Wizard?
View 13 Replies
View Related
Jul 11, 2013
I have a fill-in pdf form, with fields that match database table fields. My database is in SQL, but I use Access for the forms and reports.
The users will go on-site (and be offline), fill out the pdf forms a bunch of times and come back with a folder of them.
I am looking for a way to have a form where a user can choose a folder (maybe on an access form) and say "import PDFs" and then have all the data in the PDF forms import to the table. A lot of other stuff has to happen in that process (checking the project number on the form, assigning an ID tag for that item, etc).
View 3 Replies
View Related
Sep 2, 2013
i am trying to download an excel document from a url and the import it into a table i can successfully download the file to my desktop but when i try to import it i get the below error the Microsoft office access database engine cannot open or write to file 'C:documents and settingsJHalliweDesktop' it is already opened exclusively by another user, or you need permission to view and write its data..i have checked and the excel book is not open ( i think its trying to open while its still downloading is there away around this
Code:
Dim strUserName As String
strUserName = Environ("UserName")
Dim FolderLoc As String
FolderLoc = "C:Documents and Settings" & strUserName & "Desktop"
Dim StFile As String
Dim MySelect
MySelect = Forms!FrmIndex!Text134
[code]....
View 3 Replies
View Related
Jul 20, 2015
I have a folder that gets updated with a few new xml files every day. I need to import the data in these files into a table. The names of the files to import is in a field (FName) in a table (tblFiles).
The code that loads up the files is this:
Application.ImportXML DataSource:="C:ImportXML FILES" & FileName & ".xml", _
ImportOptions:=acAppendData
Up until now I specify the name of the file in an inputbox, so I have to enter a bunch of names to get it done.
I am looking for a way to get the filename from the table and then load up the file automatically.
View 1 Replies
View Related
Dec 28, 2013
I have an excel file on my drive with the following path "D:JsonSolve.xlsx", I only want to get "Sheet Names" and Import the sheet name into a table in Microsoft Access, how to import "All Sheet Names" from the specified path into a table, Every sheet name would be taken as a single record.
View 4 Replies
View Related
Aug 20, 2014
I am trying to automate the function that imports Infopath (.xml) data into access tables. I can have a button run the MenuCommand, but then the users have to go through all of the prompts and I just don't trust them enough to do it properly.
All I want is the user to click a button, then it lets them browse for the desired file and then imports it.
View 1 Replies
View Related
Jan 16, 2014
I need to import a html file automatically BUT my file has many tables in it, when I am doing the importation it asks about which table I want to import, the thing is that I always want every tables. The number of tables is variable. VBA code so it can have a looping which says to import every table in my HTML file?
View 1 Replies
View Related
Sep 11, 2013
I want to import email data into my access table. The email format is always same and the fields in the email match with the fileds in my table.
View 1 Replies
View Related
Nov 19, 2014
I have an Excel workbook with multiple sheets, all the sheets have the same headers and are formatted the same.
Problem 1 is I need some sort of loop so that all sheets will be imported, the names will vary so I can't use specific names to import.
Problem 2 is that I need to create a new TempTable based on the format of these sheets and have them all import to that one table.
I need to do some cleaning up and updating of the data before I run append queries to have it moved to a couple of permanent tables.
I know I've written the VBA to have a new table created on import and later deleted after all my queries run.
View 4 Replies
View Related
Nov 14, 2014
How can a reformat a number from 23 to 23.00 in a query. The format functions reformats it correctly but converts the number to text. I need to format the number as 23.00 and maintain the value as a number, not as a text. How can I do this ?
View 3 Replies
View Related
Aug 1, 2013
I am trying to build a newer database 2010, based on an older one,2000, that has been locked tight and I cannot see the modules to kinda get a reference of where to start. I am trying to find a VBA code that will allow me to import a several text files to one table. The text files are all in the same format but I cannot remove the page headers and footers to get the table to look right. I have attached an example of the text file i am trying to import but it is a stripped down version for information protection.
Also, it appears in the old Database Table once imported as:
J.Smith 1234 01 ABCD ABCD HGJV 2345 ABCDE ABC6 Qual Date Date
J.Smith 1234 01 ABCD ABCD HGJV 2345 ABCDE ABC6 Qual Date Date
J.Smith 1234 01 ABCD ABCD HGJV 2345 ABCDE ABC6 Qual Date Date
J.Adam 1234 01 ABCD ABCD HGJV 2345 ABCDE ABC6 Qual Date Date
J.Adam 1234 01 ABCD ABCD HGJV 2345 ABCDE ABC6 Qual Date Date
J.Adam 1234 01 ABCD ABCD HGJV 2345 ABCDE ABC6 Qual Date Date
If I could import the text files and end up with a table like this, it would be all i need as i could run all the queries i need from this.
View 3 Replies
View Related
May 6, 2015
I have code written which imports excel data to a access table but after the first import it fails due to duplicates, how can i tell it to ignore duplicates in the table and only copy new records?
code is below.
Code:
Function SyncEmployes()
Dim lngColumn As Long
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
[Code].....
View 6 Replies
View Related
Jul 22, 2015
I am trying to write a VBA Module that will look in a directory for Excel files with a specific file prefix, and then import specified cells into a temp table. Once it processes the first file, it copies the file to another folder, and then kills the file. However, when I run my current code, it goes through the loop the first time, but fails on the second attempt, because it is still looking for the first file it came across even though it has been moved. The code is pasted below:
Sub Count()
Dim xlwrksht As Excel.Worksheet
Dim xlWrkBk As Excel.Workbook
Dim nIndex As Integer
Dim strMvPath As String
Dim mvPath As String
Dim strFile As String
[Code] ....
View 6 Replies
View Related
Nov 19, 2014
I wanna create a button in form which can allow me to import my data base file with some tables , i would select just the variable that i need in the table not all of them .
View 2 Replies
View Related