473,811 Members | 3,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I import this data?

I have a CSV file that is tab delimited and has no text qualifiers. Normally
this would be OK, but the data has tabs in it as well!

Is there anyway I can get this data into access? Here is what the data looks
like (I have replaced the actual tabs with [TAB] for illustration purposes):

CustomerID[TAB]CustomerNotes[TAB][LINEBREAK]
0001[TAB]Likes chocolate[TAB][TAB]Hates cheese[TAB][LINEBREAK]
0002[TAB][TAB]Likes Apples[TAB][LINEBREAK][TAB]Hates Pineapple[LINEBREAK]
0003[TAB]Snores loudly[LINEBREAK][TAB][TAB]Smokes too much [TAB][LINEBREAK]
0004 etc...

Can I fix this tab delimited data with tabs and line breaks all over the
place? BTW, I can only get the data in this format i.e. we can not
manipulate it before we get the CSV file.

Thanks,

Paul

Apr 27 '06 #1
18 1480

"Paul H" <no****@nospam. com> wrote in message
news:sV******** *******@newsfe3-win.ntli.net...
I have a CSV file that is tab delimited and has no text qualifiers.
Normally this would be OK, but the data has tabs in it as well!

Is there anyway I can get this data into access? Here is what the data
looks like (I have replaced the actual tabs with [TAB] for illustration
purposes):

CustomerID[TAB]CustomerNotes[TAB][LINEBREAK]
0001[TAB]Likes chocolate[TAB][TAB]Hates cheese[TAB][LINEBREAK]
0002[TAB][TAB]Likes Apples[TAB][LINEBREAK][TAB]Hates Pineapple[LINEBREAK]
0003[TAB]Snores loudly[LINEBREAK][TAB][TAB]Smokes too much
[TAB][LINEBREAK]
0004 etc...

Can I fix this tab delimited data with tabs and line breaks all over the
place? BTW, I can only get the data in this format i.e. we can not
manipulate it before we get the CSV file.

Thanks,

Paul

This sort of thing is what Access programmers often have to do - and to do
it properly you would need to write a custom vba routine. The most
important first question is what table structure do you want it to be put
into? Typically you might use three fields: ID (just an autonumber to
identify the row), CustomerID and Notes, so the new table would be:

0001 0001 Likes chocolate
0002 0001 Hates cheese
0003 0002 Likes Apples
0004 0002 Hates Pineapple

but perhaps you have other requirements.
The second question is: can you write any vba or were you looking for
someone to write the complete routine for you?
Apr 27 '06 #2

"Anthony England" <ae******@oops. co.uk> wrote in message
news:7O******** *************** *******@bt.com. ..

"Paul H" <no****@nospam. com> wrote in message
news:sV******** *******@newsfe3-win.ntli.net...
I have a CSV file that is tab delimited and has no text qualifiers.
Normally this would be OK, but the data has tabs in it as well!

Is there anyway I can get this data into access? Here is what the data
looks like (I have replaced the actual tabs with [TAB] for illustration
purposes):

CustomerID[TAB]CustomerNotes[TAB][LINEBREAK]
0001[TAB]Likes chocolate[TAB][TAB]Hates cheese[TAB][LINEBREAK]
0002[TAB][TAB]Likes Apples[TAB][LINEBREAK][TAB]Hates Pineapple[LINEBREAK]
0003[TAB]Snores loudly[LINEBREAK][TAB][TAB]Smokes too much
[TAB][LINEBREAK]
0004 etc...

Can I fix this tab delimited data with tabs and line breaks all over the
place? BTW, I can only get the data in this format i.e. we can not
manipulate it before we get the CSV file.

Thanks,

Paul

This sort of thing is what Access programmers often have to do - and to do
it properly you would need to write a custom vba routine. The most
important first question is what table structure do you want it to be put
into? Typically you might use three fields: ID (just an autonumber to
identify the row), CustomerID and Notes, so the new table would be:

0001 0001 Likes chocolate
0002 0001 Hates cheese
0003 0002 Likes Apples
0004 0002 Hates Pineapple

but perhaps you have other requirements.
The second question is: can you write any vba or were you looking for
someone to write the complete routine for you?


Thanks Anthony,

Sorry I didn't explain myself very well. It is just two fields; CustomerID
and Notes. it should look like this:

CustomerID Notes
0001 Likes chocolate Hates cheese
0002 Likes Apples Hates Pineapple

The problem is that the Notes data has random Tabs and line breaks in it. I
am comfortable writing VBA but have no idea where to start with this data
because I can not predict where and how many tabs or linebreaks there will
be in each Notes field. I would appreciate any pointers.

Regards,

Paul
Apr 27 '06 #3
"Paul H" <no****@nospam. com> wrote in
news:sV******** *******@newsfe3-win.ntli.net:
I have a CSV file that is tab delimited and has no text qualifiers.
Normally this would be OK, but the data has tabs in it as well!

Is there anyway I can get this data into access? Here is what the data
looks like (I have replaced the actual tabs with [TAB] for
illustration purposes):

CustomerID[TAB]CustomerNotes[TAB][LINEBREAK]
0001[TAB]Likes chocolate[TAB][TAB]Hates cheese[TAB][LINEBREAK]
0002[TAB][TAB]Likes Apples[TAB][LINEBREAK][TAB]Hates
Pineapple[LINEBREAK] 0003[TAB]Snores loudly[LINEBREAK][TAB][TAB]Smokes
too much [TAB][LINEBREAK] 0004 etc...

Can I fix this tab delimited data with tabs and line breaks all over
the place? BTW, I can only get the data in this format i.e. we can not
manipulate it before we get the CSV file.


It's quite possible to write VBA code that parses and imports this data.
I'm hesitant because of many experiences where the poster responds:

Well, I'm using Access 97 and Replace doesn't work;
Well, that's not what the data are really like; I was just giving an
example and while your solution works on the example, it won't work on
the "real" thing;
Well, the ids actually range from 1 to 100000; I just put the 000?
pattern there so it would look good in the post.
or doesn't respond with:
Well, I've never seen anything like that before so I won't even try it.

If you'd like some possible solutions I suggest that you make some part
of the file available preferable as a download from a web-server, specify
what version of Access you are using and clearly state how we may
identify IDs.

I expect you are already aware from other answers that you db design may
be suspect. A primary rule of db design is that columns be atomic, that
they describe a single attribute. Your notes field is not. This may be
the foundation for your problem, even though it appears that it's a
problem with the CSV file.

Regardless, writing the code you are wondering about is a ten minute job,
when we know the rules and the background.

--
Lyle Fairfield
Apr 27 '06 #4

"Paul H" <no****@nospam. com> wrote in message
news:c2******** *********@newsf e2-win.ntli.net...

"Anthony England" <ae******@oops. co.uk> wrote in message
news:7O******** *************** *******@bt.com. ..

"Paul H" <no****@nospam. com> wrote in message
news:sV******** *******@newsfe3-win.ntli.net...
I have a CSV file that is tab delimited and has no text qualifiers.
Normally this would be OK, but the data has tabs in it as well!

Is there anyway I can get this data into access? Here is what the data
looks like (I have replaced the actual tabs with [TAB] for illustration
purposes):

CustomerID[TAB]CustomerNotes[TAB][LINEBREAK]
0001[TAB]Likes chocolate[TAB][TAB]Hates cheese[TAB][LINEBREAK]
0002[TAB][TAB]Likes Apples[TAB][LINEBREAK][TAB]Hates
Pineapple[LINEBREAK]
0003[TAB]Snores loudly[LINEBREAK][TAB][TAB]Smokes too much
[TAB][LINEBREAK]
0004 etc...

Can I fix this tab delimited data with tabs and line breaks all over the
place? BTW, I can only get the data in this format i.e. we can not
manipulate it before we get the CSV file.

Thanks,

Paul

This sort of thing is what Access programmers often have to do - and to
do it properly you would need to write a custom vba routine. The most
important first question is what table structure do you want it to be put
into? Typically you might use three fields: ID (just an autonumber to
identify the row), CustomerID and Notes, so the new table would be:

0001 0001 Likes chocolate
0002 0001 Hates cheese
0003 0002 Likes Apples
0004 0002 Hates Pineapple

but perhaps you have other requirements.
The second question is: can you write any vba or were you looking for
someone to write the complete routine for you?


Thanks Anthony,

Sorry I didn't explain myself very well. It is just two fields; CustomerID
and Notes. it should look like this:

CustomerID Notes
0001 Likes chocolate Hates cheese
0002 Likes Apples Hates Pineapple

The problem is that the Notes data has random Tabs and line breaks in it.
I am comfortable writing VBA but have no idea where to start with this
data because I can not predict where and how many tabs or linebreaks there
will be in each Notes field. I would appreciate any pointers.

Regards,

Paul


OK if you are comfortable writing vba then I'll help with the bit you can't
do, and you can do the rest by replacing the WriteRecord routine with code
that genuinely writes out the data rather than simply putting it in the
debug window.
In case any explanation is needed it reads the file line by line and if it
comes to a line which starts with 0002[TAB] then it knows a new record is
beginning.
' *************** *************** ************
' Code Starts
' *************** *************** ************
Option Compare Database
Option Explicit

Public Function DoImport(strPat h As String) As Boolean

On Error GoTo Err_Handler

Dim intFile As Integer
Dim strLine As String
Dim blnOpen As Boolean
Dim strRecord As String

intFile = FreeFile

Open strPath For Input Access Read Lock Write As #intFile

blnOpen = True

If Not EOF(intFile) Then
' Take the first line and ignore it
Line Input #intFile, strLine
End If

While Not EOF(intFile)
Line Input #intFile, strLine
If strLine Like "####" & Chr$(9) & "*" Then
WriteRecord strRecord
strRecord = strLine
Else
strRecord = strRecord & strLine
End If
Wend

WriteRecord strRecord

DoImport = True

Exit_Handler:

If blnOpen Then
Close intFile
End If

Exit Function

Err_Handler:
MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function

Private Sub WriteRecord(str Record As String)

Dim lngCusID As Long
Dim strNotes As String

If strRecord Like "####" & Chr$(9) & "*" Then
lngCusID = CLng(Left$(strR ecord, 4))
strNotes = Mid$(strRecord, 6)
Else
Exit Sub
End If

Debug.Print Format(lngCusID , "0000") & " " & strNotes

End Sub

' *************** *************** ************
' Code Ends
' *************** *************** ************


Apr 27 '06 #5
> It's quite possible to write VBA code that parses and imports this data.
I'm hesitant because of many experiences where the poster responds:

Well, I'm using Access 97 and Replace doesn't work;
Well, that's not what the data are really like; I was just giving an
example and while your solution works on the example, it won't work on
the "real" thing;
Well, the ids actually range from 1 to 100000; I just put the 000?
pattern there so it would look good in the post.
or doesn't respond with:
Well, I've never seen anything like that before so I won't even try it.
<snip> Lyle Fairfield

I'm eagerly anticipating one or more of those responses!
However you have omitted what actually must be the most common response - no
response.
Apr 27 '06 #6
"Anthony England" <ae******@oops. co.uk> wrote in
news:Hr******** ************@bt .com:
I'm eagerly anticipating one or more of those responses!
However you have omitted what actually must be the most common
response - no response.


Does this have something to do with nulls?

--
Lyle Fairfield
Apr 27 '06 #7
"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:Xn******** *************** **********@216. 221.81.119...
"Anthony England" <ae******@oops. co.uk> wrote in
news:Hr******** ************@bt .com:
I'm eagerly anticipating one or more of those responses!
However you have omitted what actually must be the most common
response - no response.


Does this have something to do with nulls?

--
Lyle Fairfield

Not connected to the current post, but I genuinely wonder what is with these
people who appear, ask a question, get a very helpful and detailed response
but never appear again. Was the post even read?
I also am genuinely puzzled by my inability to accept that this is the way
it works, and that if you are looking for any response, it would be better
to get this via paid employment where not only are you sure that your work
is seen by others, but you are rewarded with cash - amazing! I need to get
a job!
Apr 27 '06 #8
"Anthony England" <ae******@oops. co.uk> wrote in
news:pN******** *************** *******@bt.com:
Not connected to the current post, but I genuinely wonder what is with
these people who appear, ask a question, get a very helpful and
detailed response but never appear again. Was the post even read?
I also am genuinely puzzled by my inability to accept that this is the
way it works, and that if you are looking for any response, it would
be better to get this via paid employment where not only are you sure
that your work is seen by others, but you are rewarded with cash -
amazing! I need to get a job!


LOL! I recommend you get one or more persons of your sexual preference and
hole up with them for a few years living on welfare while you consider all
this carefully! When you get to be my age you may wonder whether this job
thing and the dedication to it, and even the economic benefits, were
really, really the best way you could have spent your life.

And gratitude here? Sometimes, but not often. Maybe it's because they
didn't understand your answer, or realized upon reading it that their whole
db is just crap and chose to slink away rather than confront their own work
and level of accomplishment.

Something like I'm doing with ASP.net right now where I say, "Do I really
wanna expend the energy, and experience the frustrations necessary to
become capable with this? Maybe I should just slip over to Woodbine and put
a few shekels on Big Red Underwear in the seventh."

--
Lyle Fairfield
Apr 27 '06 #9

"Lyle Fairfield" <ly***********@ aim.com> wrote in message
news:Xn******** *************** **********@216. 221.81.119...
"Anthony England" <ae******@oops. co.uk> wrote in
news:pN******** *************** *******@bt.com:
Not connected to the current post, but I genuinely wonder what is with
these people who appear, ask a question, get a very helpful and
detailed response but never appear again. Was the post even read?
I also am genuinely puzzled by my inability to accept that this is the
way it works, and that if you are looking for any response, it would
be better to get this via paid employment where not only are you sure
that your work is seen by others, but you are rewarded with cash -
amazing! I need to get a job!


LOL! I recommend you get one or more persons of your sexual preference and
hole up with them for a few years living on welfare while you consider all
this carefully! When you get to be my age you may wonder whether this job
thing and the dedication to it, and even the economic benefits, were
really, really the best way you could have spent your life.

And gratitude here? Sometimes, but not often. Maybe it's because they
didn't understand your answer, or realized upon reading it that their
whole
db is just crap and chose to slink away rather than confront their own
work
and level of accomplishment.

Something like I'm doing with ASP.net right now where I say, "Do I really
wanna expend the energy, and experience the frustrations necessary to
become capable with this? Maybe I should just slip over to Woodbine and
put
a few shekels on Big Red Underwear in the seventh."

--
Lyle Fairfield



I like the holing up idea. Although I wonder if the line about "one or more
persons of your sexual preference". I would prefer to hole up with someone
with the opposite sexual preference - not all Englishmen are gay, you know.

Apr 27 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1827
by: Olivier Noblanc ATOUSOFT | last post by:
Hello, In the botom of this post you will see my source code. The problem is when i launch main.py that doesn't make anything why ? Thanks olivier noblanc Atousoft http://www.logiciel-erp.fr
3
6274
by: Doug Baroter | last post by:
Hi, One of my clients has the following situation. They use Access DB for data update etc. some business functions while they also want to view the Access data quickly and more efficiently in SQL Server 2000. Huge Access db with over 100 user tables, over 60 MB data. The DTS package that comes with SQL Server 2000 seems pretty "messy" in the sense that it assumes that one needs to do one time import only or accurately it does not...
1
9758
by: DCM Fan | last post by:
Access 2K, SP3 on Windows 2K, SP4 All, I have an import spec set up with quoted Identifiers and comma-separated values. The text file is produced by a 3rd-party program of which I have no control. It outputs all text fields surrounded by quotes, and all numeric fields w/o quotes. All fields are separated with commas. This has been working for 2 years, until today, when one of the data fields
1
6706
by: Dan | last post by:
Could someone please help me with auto importing a series of data files into an Access table. I tried to follow code given below in a previous messagebut i'm getting error messages. Here's my database stats: Path: C:\Database (contains the database and all the text files to be imported) Text files to import: (SampleData4.txt and SampleData3.txt as testing examples)
4
3030
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not coming to a firm conclusion over whether it was the better approach, and wonder if I should do it differently the next time I'm faced with a similar issue. I needed an app to automatically import from spreadsheets with a semi-dynamic structure,...
3
3721
by: deko | last post by:
I've been trying to use the Access Import Wizard to expedite importing data into my mdb. The nice thing about the wizard is that I can import from different file formats - txt, xls, even Outlook - and dump everything into a table. The problem is once I have the data imported into a new table, I can't do much with it. If I try to run an Append query and insert data from the new table into an existing table, the query fails - "Error...
10
2568
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all the capabilities of what I have available. I can learn the details myself I think. I am trying to set this up to be as simple to use as possible since others will be importing data on a weekly or daily basis. I need to import some text files,...
4
6114
by: Bruce W. Roeser | last post by:
All, I'm reading a book by Charles Petzold (Programming VS.Net). Pretty good content but am confused about the difference. From the text: ---------------------------------------------------------------------------------------------------------------------------------------------------------- The @ Import Directive Next to @ Page, the directive that ASP.NET programmers use the most is @ Import. The @ Import directive is ASP.NET's...
3
2308
by: Chris | last post by:
Hi, 1) In file test.aspx, i put: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %> <%@ import namespace="System.Data"%> <%@ import namespace="System.Data.OleDb"%> .... In file test.aspx.vb, i put:
10
1610
by: nisp | last post by:
Hi all ! I'm trying to capture stderr of an external module I use in my python program. I'm doing this by setting up a class in my module overwriting the stderr file object method write. The external module outputs to stderr this way: from sys import std err
0
9727
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.