bobaol
Board Regular
- Joined
- Jun 3, 2002
- Messages
- 225
- Office Version
- 365
- 2003 or older
- Platform
- Windows
Hello, I have a lot of files with a lot of dirty data. I want PowerQuery to import everything as text, regardless of the data. I tried this, but it is not working. I don't need PowerQuery to parse the data, although I want to keep the file name in column A.
let
Source = Folder.Files("C:\Temp2\6267b"),
#"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File")))
in
#"Expanded Table Column1"
''---------------------------------------------------------
I tried this for a single file, and it works, but I have a few thousand files.
let
/* Get the raw line by line contents of the file, preventing PQ from interpreting it */
fnRawFileContents = (fullpath as text) as table =>
let
Value = Table.FromList(Lines.FromBinary(File.Contents(fullpath)),Splitter.SplitByNothing())
in Value,
/* Use function to load file contents */
Source = fnRawFileContents("C:\Temp2\count_Distinct_6267\test6266.csv")
/*Source = fnRawFileContents("C:\Temp2\count_Distinct_6267\")*/
any help is appreciated. Thanks in advance.
let
Source = Folder.Files("C:\Temp2\6267b"),
#"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File")))
in
#"Expanded Table Column1"
''---------------------------------------------------------
I tried this for a single file, and it works, but I have a few thousand files.
let
/* Get the raw line by line contents of the file, preventing PQ from interpreting it */
fnRawFileContents = (fullpath as text) as table =>
let
Value = Table.FromList(Lines.FromBinary(File.Contents(fullpath)),Splitter.SplitByNothing())
in Value,
/* Use function to load file contents */
Source = fnRawFileContents("C:\Temp2\count_Distinct_6267\test6266.csv")
/*Source = fnRawFileContents("C:\Temp2\count_Distinct_6267\")*/
any help is appreciated. Thanks in advance.