text file export format

I’ve been struggling with creating a .txt file using the dataset.getAsText() function in combination with plugins.file.writeTXTFile().

I need to export a specifically formatted text file where each field (each row only contains 1 field in the dataset) occupies a new line in the .txt file, thus:

FIELD CONTENT
FIELD CONTENT
FIELD CONTENT
FIELD CONTENT

There should be no delimiter for the fields.

I am using the following code:

var txtFile = dataset.getAsText(null,'\n',null,false);

but the .txt file, when opened in notepad looks like this:

FIELD CONTENTFIELD CONTENTFIELD CONTENTFIELD CONTENT

Anyone have any ideas? Not sure what (if anything) I am doing wrong.

\n is a line feed. you could try \r, which is a carriage return.

Unfortunately I’ve tried ‘\r’ as well, with the same result.

Any other ideas how I can get this format right?

OK. I did some research. It looks like Windows uses carriage return AND a line feed as new line, while other systems only use a line feed.

So in my tests this works: \r\n

Thanks Patrick, works great, you’re a life saver!

Pretty important text file, huh? :lol:

Yeah, its formatted to be read by one of our business partners automated systems and contains important account info, their system rejects inproperly formatted files.

This solution is currently running in Filemaker but we are migrating it, so it would have been a pretty big show stopper…