Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Matthiaskirsch
New Member

Text files

Dear all,

 

being an absolute greehorn, I would appreciate getting instruction how to use Powerquery and the associateeditor for the following problem:

I have a folder with .txt- files, each consisting of a single column of data without header. These should be combined into a single excel worksheet with names of files as column headers, each column containing data from a single file?
So far I have only managed to combine the files yielding a single colum of data: the first column contain the name of the txt-file repeated as often as there are data rows in the file.
However, I want the content of the single data column of each file in separate colums in the resulting worksheet (only one worksheet with as many columns as there are txt-files.
Ideally this worksheet should get updated each time I add a new txt-file to the source folder.
 
Hope I made the problem clear enough for anybody out there to provide a working solution.
Thanks in advance and best,
Matthias
 
 
 
 
Von Samsung-Tablet gesendet
1 ACCEPTED SOLUTION

let
  Quelle = Folder.Files("C:\Users\kirsch\Desktop\text"),
  custom1 = Table.FromColumns(List.Transform(Quelle[Content], each Lines.FromBinary(_)),Quelle[Name])
in
  custom1

View solution in original post

9 REPLIES 9
wdx223_Daniel
Super User
Super User

let

source=Folder.Files(YourPath),

custom1=Table.FromColumns(List.Transform(source[Content],each "your code to import text files"),source[Name])

in

custom1

So I just learned, that it is you, whom I have to thank for the working code. THANKX,

Matthias

 

Just made a mistake and replied to myself, which of course is stupid.

Hi Daniel,

thanks!

However, this does not seem to be the whole code.

I cannot figure out what you mean with: "your code to import text files"

As I said, I am completely new to PQ and really would appreciate a complete working solution. I may learn along the way, but for now, I have no clue (and little time)  apart from what I learn from tutorial videos and I have not found one, which matches my problem.

 

I am using Excel2016 by the way.

 

Best,

Matthias

So I just learned, that it is you, whom I have to thank for the working code. THANKX,

Matthias

Hello, @Matthiaskirsch . Try to replace "your code to import text files" with Lines.FromBinary(_) in the code provided by @wdx223_Daniel 

Hi AlienSx,

 

I guess I am just to dump. So this is what I see in the PQ-Editor:

let
Quelle = Folder.Files("C:\Users\kirsch\Desktop\text"),
custom1=Table.FromColumns(List.Transform(Quelle[Content],each "Lines.FromBinary(_) "),Quelle[Name])
in
custom1

 

Then I get the following error:

Expression.Error: Der Wert ""Lines.FromBinary(_) "" kann nicht in den Typ "List" konvertiert werden.
Details:
Value=Lines.FromBinary(_)
Type=Type

 

???

Best,

Matthias

 

let
  Quelle = Folder.Files("C:\Users\kirsch\Desktop\text"),
  custom1 = Table.FromColumns(List.Transform(Quelle[Content], each Lines.FromBinary(_)),Quelle[Name])
in
  custom1

Dear AlienSx,

 

you are a genius. So simple and it works like a charm.

Thank you so much, this will help me a lot and my generate some more questions in the future, now that I have seen that I get useful answers this quick.

Best,

Matthias

it's @wdx223_Daniel who provided a solution to be honest. But thank you.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors