473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exporting Empty fields into .txt

Hello all,

I'm trying to export a the results of a query into a comma delimited .txt with the header colum. The fist column is always blank.The current format is

Header:
XXXX {Tab} XXX_XX {Tab} {Tab} {Tab} XX_XXXX_XX {Tab} XXXXX
Body:
{Tab}xxxxxxxxxxxxxxxxxx {Tab}xxxxxxx{Tab}xxxxxxxxx

I'm exporting the results of a make table query in the same format with comma's as the delimiter. Problem is in the header there is two delimiters between the second and third text column. I cant get the specs right to export a blank column. I'v tried using a , as the column name but the export comes out with an underhyphen as the name not a comma.
Oct 20 '06 #1
11 3185
MMcCarthy
14,534 Expert Mod 8TB
Try using the | as the delimiter



Hello all,

I'm trying to export a the results of a query into a comma delimited .txt with the header colum. The fist column is always blank.The current format is

Header:
XXXX {Tab} XXX_XX {Tab} {Tab} {Tab} XX_XXXX_XX {Tab} XXXXX
Body:
{Tab}xxxxxxxxxxxxxxxxxx {Tab}xxxxxxx{Tab}xxxxxxxxx

I'm exporting the results of a make table query in the same format with comma's as the delimiter. Problem is in the header there is two delimiters between the second and third text column. I cant get the specs right to export a blank column. I'v tried using a , as the column name but the export comes out with an underhyphen as the name not a comma.
Oct 20 '06 #2
Working for a utility company and we were only allowed to test transactions once using a comma and a period. I don't know if the receiving system will accept a pipe for the delimiter.
Oct 20 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
When you do the export click on the advanced tab. You will see a list of the fields displayed and can manipulate them, even hide them. You can also save your changes as a specification for future use.



Hello all,

I'm trying to export a the results of a query into a comma delimited .txt with the header colum. The fist column is always blank.The current format is

Header:
XXXX {Tab} XXX_XX {Tab} {Tab} {Tab} XX_XXXX_XX {Tab} XXXXX
Body:
{Tab}xxxxxxxxxxxxxxxxxx {Tab}xxxxxxx{Tab}xxxxxxxxx

I'm exporting the results of a make table query in the same format with comma's as the delimiter. Problem is in the header there is two delimiters between the second and third text column. I cant get the specs right to export a blank column. I'v tried using a , as the column name but the export comes out with an underhyphen as the name not a comma.
Oct 20 '06 #4
Specifications in Fixed Width won't let me have a header and Specifications in Delimited wont let me have a nameless column in the header.
Oct 20 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Specifications in fixed width do let you have a header.

In the normal wizard on fixed width, when you get to the window that shows the column. double click where you want the second column to appear and it will be created.

Then go to advanced and name/rename it

Specifications in Fixed Width won't let me have a header and Specifications in Delimited wont let me have a nameless column in the header.
Oct 20 '06 #6
Forgive me for my ignorance but the only boxs I'm seeing is the Sample export Format with the Fixed Width radio button clicked. Or under advanced when I add a column with no name I get the error : "The number of fields in your export specs does not match the number of fields in the table you have chosen to export."
Oct 20 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
What exactly are you trying to export?
Why do you need an empty field?
Open your query in design view, then change to SQL view and copy and paste the code here.

Forgive me for my ignorance but the only boxs I'm seeing is the Sample export Format with the Fixed Width radio button clicked. Or under advanced when I add a column with no name I get the error : "The number of fields in your export specs does not match the number of fields in the table you have chosen to export."
Oct 20 '06 #8
o.k. I have a table with 4 colums SOAR ESI_ID CR_DUNS_NO BGN06
The SOAR column will never have any information in it. The ESI_ID column will be 17 numbers wide, the CR_DUNS_NO can have up to 15 numbers in it and the BGN06 column can have up to like 25 or 30 alpha or numeric. Right now I run a SQL query in a different program and export it to EXCEL. Then I copy the ESI_ID, CR_DUNS_NO, and BGN06 and paste it to a .txt file. The .txt already has a header and I paste my data under the header. Then I have to insert a Tab in front of every line to make the data line up for the last three colums and leave the first column empty. All in all it needs to look like this

SOAR,ESI_ID,,,CR_DUNS_NO,,BGN_06
, data , data, data

The SQL query is as follows

INSERT INTO 86702PayloadToDrop ( ESI_ID, CR_DUNS_NO, BGN06 )
SELECT [86702HU].ESI_ID, [86702HU].CR_DUNS_NO, [86702HU].BGN06
FROM 86702HU
WHERE ((([86702HU].[Run Date])=Date()-1));

It's an append query (sorry for misinforming earler) and the table appended to already has SOAR for the first column.
Oct 20 '06 #9
MMcCarthy
14,534 Expert Mod 8TB
Why are you exporting the SQL query to excel why not send it directly to a text file.

I think the reason I can't seem to help is that I really don't know what you're doing.

Forgeting what you're doing at the moment. The more information you are giving me about sql to excel to text to ?? the more confused I'm getting.

Can you tell me what you need to happen in the future. You have a SQL query that much is fine.

What has to happen after that and what do you want to end up with exactly.

I really want to help but I'm very confused.


o.k. I have a table with 4 colums SOAR ESI_ID CR_DUNS_NO BGN06
The SOAR column will never have any information in it. The ESI_ID column will be 17 numbers wide, the CR_DUNS_NO can have up to 15 numbers in it and the BGN06 column can have up to like 25 or 30 alpha or numeric. Right now I run a SQL query in a different program and export it to EXCEL. Then I copy the ESI_ID, CR_DUNS_NO, and BGN06 and paste it to a .txt file. The .txt already has a header and I paste my data under the header. Then I have to insert a Tab in front of every line to make the data line up for the last three colums and leave the first column empty. All in all it needs to look like this

SOAR,ESI_ID,,,CR_DUNS_NO,,BGN_06
, data , data, data

The SQL query is as follows

INSERT INTO 86702PayloadToDrop ( ESI_ID, CR_DUNS_NO, BGN06 )
SELECT [86702HU].ESI_ID, [86702HU].CR_DUNS_NO, [86702HU].BGN06
FROM 86702HU
WHERE ((([86702HU].[Run Date])=Date()-1));

It's an append query (sorry for misinforming earler) and the table appended to already has SOAR for the first column.
Oct 20 '06 #10
o.k. I use a Golden 32 program to run queries off of a SQL server. Golden 32 will export to Excel, CSV, or XML. Right now we run the query 2 times daily and save the results to an Excel file for data integrity. Then I align the data into a .txt file and put it into a folder. Twice a day an automated system sweeps the folder and imports the .txt file. Whatever data I have on the .txt file get's turned into the different transactions and gets sent off to whereever it goes. I'm trying to automate this so that we run the query, save it to a location, click a button in the database and it imports the xls, creates the table needed and exports a txt. The data results from the SQL query are as follows:

Column A Column B Column C
ESI_ID CR_DUNS_NO BGN06
1044372000XXXXXXX XXXXXXXXX XXXXXXXXXXXXXXXXXXXXX

The .txt file that I create looks like this, with a Tab between each field

SOAR ESIID REPID REPREF
1044372000XXXXXXX XXXXXXXXX XXXXXXXXXXXXXXXX

The .txt file that I need should look like

SOAR,ESIID,,,REPID,,REPREF
,1044372000XXXXXXX,XXXXXXXX,XXXXXXXXXXXXXXX

With 3 comma delimiters between ESIID and REPID and 2 comma delimiters between REPID and REPREF. Sorry for so much confusion.
Oct 23 '06 #11
MMcCarthy
14,534 Expert Mod 8TB
Column A Column B Column C
ESI_ID CR_DUNS_NO BGN06
1044372000XXXXXXX XXXXXXXXX XXXXXXXXXXXXXXXXXXXXX

Put the following function in a module and run it to import the above to access having created an appropriate table with the following text fields

ESI_ID
CR_DUNS_NO
BGN06

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function readTextFile(ByVal fpath As String)
  3. On Error GoTo Err_readTextFile
  4. Dim db As Database
  5. Dim rs As Recordset
  6. Dim fhandle1 As Integer
  7. Dim fline As String
  8. Dim tempValue1 As String
  9. Dim tempValue2 As String
  10. Dim tempValue3 As String
  11. Dim i As Integer
  12.     ' open the text file to be read
  13.     fhandle1 = FreeFile()
  14.     Open fpath For Input Access Read Lock Write As #fhandle1
  15.  
  16.     Set db = CurrentDb
  17.     Set rs = db.OpenRecordset("NewTableName") ' replace with your table name
  18.  
  19.  
  20.     Do While Not EOF(fhandle1) ' loop until you reach the end of the file.
  21.         Line Input #fhandle1, fline
  22.         fline = Trim(fline)  ' cut off spaces
  23.  
  24.         If IsNumeric(Left(fline,1)) Then ' this will ignore headers
  25.             tempValue = ""
  26.  
  27.             For i=0 To Len(fline)-1
  28.                 If (Mid(fline,i,1) <> " ") And (i < 21) Then
  29.                     tempValue1=tempValue1 & Mid(fline,i,1)
  30.                 ElseIf (Mid(fline,i,1) <> " ") And (i >= 21 And i < 35) Then
  31.                     tempValue2=tempValue2 & Mid(fline,i,1)
  32.                 ElseIf (Mid(fline,i,1) <> " ") And (i >= 35) Then
  33.                     tempValue3=tempValue3 & Mid(fline,i,1)
  34.                 Else
  35.                 End If
  36.  
  37.                 rs.AddNew
  38.                 rs!ESI_ID = tempValue1
  39.                 rs!CR_DUNS_NO = tempValue2
  40.                 rs!BGN06 = tempValue3
  41.                 rs.Update
  42.             Next i    
  43.          End If   
  44.     Loop
  45.  
  46.     Close #fhandle1
  47.     Close #fhandle2
  48.  
  49.     rs.Close
  50.     Set rs=Nothing
  51.     Set db=Nothing
  52.  
  53. Exit_readTextFile:
  54. Exit Function
  55. Err_readTextFile:
  56.     Select Case Err
  57.     Case 0      '.insert Errors you wish to ignore here
  58.         Resume Next
  59.     Case Else   '.All other errors will trap
  60.         Beep
  61.         MsgBox Err.Description, , "Error in Function Text File Handler.readTextFile"
  62.         Resume Exit_readTextFile
  63.     End Select
  64.     Resume 0    '.FOR TROUBLESHOOTING
  65. End Function
  66.  
  67.  
This will give you a table of data in Access that you can manipulate and append to a table with the following fields as appropriate.

SOAR ESIID REPID REPREF

You can use substitute labels for the blank field labels like Expr1. If you get the above working I will show you how to export the results to a csv file as below.

SOAR,ESIID,,,REPID,,REPREF
,1044372000XXXXXXX,XXXXXXXX,XXXXXXXXXXXXXXX
Oct 23 '06 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ali Eghtebas | last post by:
Hi, I tried this demo application in here (watch for any line breaks in the URL): (http://support.crystaldecisions.com/communityCS/FilesAndUpdates/vbnet_win_a dodotnet.exe.asp When exporting...
1
by: Jacky11 | last post by:
I have a column name the Data type is MEMO The input is more than thousands of characters. When exporting, not all the information is exported. Who can I correct this problem? Thanks
2
by: G | last post by:
When I export data from access to excel by with "export" or "Analyze with" I seem to loose parts of some fields (long text strings). Is there a way to export it all to excel? Thanks G
1
by: warlord | last post by:
In order to save typing, I've borrowed the text from a post of nearly 12 months ago.....but the problem still exists. I've been banging my head all day with this, so I'm hoping someone has some...
6
by: Kevin Chambers | last post by:
Hi all-- In an attempt to commit an Access MDB to a versioning system (subversion), I'm trying to figure out how to convert a jet table's metadata to text, a la SaveAsText. The end goal is to...
21
by: bobh | last post by:
Hi All, In Access97 I have a table that's greater than 65k records and I'm looking for a VBA way to export the records to Excel. Anyone have vba code to export from access to excel and have the...
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
1
by: mailjaneen | last post by:
Hello, can someone help me. I want to display some fields on a report in print preview (i.e. instructions), that I don't want to print to the printer or export to file. I can't seem to find any...
7
by: leninv | last post by:
Hi, I have the following code where 'recs' is a record set. For i=0 to recs.Fields.Count - 1 if i = 0 then pindnt = string(itmlvl*2," ") response.write pindnt &...
0
by: taylorcarr | last post by:
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,...
0
by: aa123db | last post by:
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.