Need help with importing non standard CVS/TXT

jmckeone

Well-known Member
Joined
Jun 3, 2006
Messages
550
A co-worker would like to turn some data into a format from which we can generate a usage/functional report.

All data doesn't reside in one file but in 208 files.

Is there any moderately painless approach to merge all the data into one workbook?
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
OK ... I decided to record a macro to see what a single import looked like in hopes one of you excel gurus might be able to help me refine the code to import and append all CSV files in the given directory to the current Sheet1 of the active workbook.

Code:
Sub TxtImport()
'
' TxtImport Macro
' record importing CSV and formatting fields and indicating separators
'

'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Documents and Settings\E012884\Desktop\Diane\CLMBOH-WIS-SMC-8014WG.csv" _
        , Destination:=Range("$A$1"))
        .Name = "CLMBOH-WIS-SMC-8014WG"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 437
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileOtherDelimiter = "|"
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
End Sub
 
Upvote 0
Problem solved.

Sometimes us computer geeks look for a complex and elegant solution when something simple will do.

Turned out to be painfully simple and utilized an old DOS command

Code:
copy *.csv final.csv

Imported resulting file
Removed duplicate headers
Used Data\Text to columns to break it into columns

Hopefully someone else will run across this post and save themselves the extra trouble as a result.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top