|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Here's my problem, I have a .txt file that contains data that needs to be seperated by tabs and cant figure out how to write a code that will seperate the data for me. So that when I pull it into excel it's not read as one big cell of information, instead its seperated by tabs. Any help or direction to where i could go would be helpful. I'm programming in BASIC and the compiler is BASIC IDE. thanks in advance
|
| Sponsored Links |
|
|
|
|||||
|
Do you know something more precise for where to insert the tabs?
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||
|
Thanks for your help so far, I have txt file that needs to be tab delimited. I would like to do a find a replace with tabs. the character that is being replaced is (|) this in not an "L" by the way. so i'm not sure if how to write the code for that.
Thanks |
|
|||||
|
I'm not sure if this is the type of solution you are looking for, but when importing external data into excel you can specify the delimiting character in the Import Text Wizard. Just uncheck the "Tab" box and check "Other", then specify the | character in the following text box.
|
| Sponsored Links |
|
|
|
|||
|
thank you for your reply, but I know how to do that. I'm trying to automate the process so I wont have to do that (LOL). I know that it's probably something simple, but can't put my hands around it. When i pull the file into excel its not recognizing the tabs, it just reads it as spaces and continues putting all the information into that one block of cell. It's really frustrating, so I'm not sure what i need to do?????? any suggestions or website are helpful.
Thanks |
|
|||||
|
I would just read the source file one character at a time, replacing the | with [tab] when encountered, then write the character to a new file. You just need to do a little experimenting to figure out the ASCII code for | and [tab].
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||
|
assumed input data like this:
123|456|789 one|two|three Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Cells(1, 1).Value = "First Column header"
objSheet.Cells(1, 2).Value = "Second column header"
objSheet.Cells(1, 2).Value = "third column header"
r = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
myFile = "c:\temp\a.txt"
Set objFile = objFSO.OpenTextFile(myFile,1)
Do Until objFile.AtEndOfStream
line = Split(Replace(objFile.ReadLine,"|",vbTab),vbTab )
WScript.Echo line(1)
objSheet.Cells(r, 1).Value = line(0)
objSheet.Cells(r, 2).Value = line(1)
objSheet.Cells(r, 3).Value = line(2)
r=r +1
Loop
objExcel.ActiveWorkbook.SaveAs "c:\test.xls"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Contest: C# vs. Java vs. Visual Basic | Jordan | General Programming | 259 | 11-10-2008 03:53 PM |
| HTML Basic Formatting | clookid | Tutorials | 14 | 03-06-2007 04:10 PM |
| My friend made some cool BASIC videos | elfshadow14 | The Lounge | 5 | 01-09-2007 11:20 PM |
| Graphical programming add-in for Visual Basic 6.0 | xXHalfSliceXx | Visual Basic Programming | 10 | 01-03-2007 08:14 AM |
| Parallel Port Programming Using Visual Basic | kevintcp85 | Visual Basic Programming | 12 | 12-06-2006 01:09 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%