create text file with a new line with each append

1,830 views
Skip to first unread message

SS TheAppInventor

unread,
Nov 21, 2016, 7:22:47 AM11/21/16
to MIT App Inventor Forum
Hi all, I am writing an app that appends 2 textbox text into a text file. I am using \n  after each write for the carriage return but the text file that AI2 creates looks like this:

" 363627" " ryuwuwiw" " 373636e6" "dhhehsjs " " 477372u" " ruejjej"

I need the file to be in following format so I can read the text as tab delimited file on a windows app:

" 363627" " ryuwuwiw"
" 373636e6" "dhhehsjs "
" 477372u" " ruejjej"

Any suggestion will be kindly appreciated!

Kind regards,
Sal

Taifun

unread,
Nov 21, 2016, 8:42:52 AM11/21/16
to MIT App Inventor Forum
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

SS TheAppInventor

unread,
Nov 21, 2016, 8:49:48 AM11/21/16
to mitappinv...@googlegroups.com
Thanks for your reply Taifun. I have attached the block that I am using to write to text file.


ap2.JPG

Taifun

unread,
Nov 21, 2016, 9:28:00 AM11/21/16
to MIT App Inventor Forum
you can try to put your values into a list of lists and then use the list to csv table block together with the File.SaveFile block
Taifun

SS TheAppInventor

unread,
Nov 21, 2016, 9:38:45 AM11/21/16
to MIT App Inventor Forum
Thanks Taifun - do you have any example I can follow?

Taifun

unread,
Nov 21, 2016, 9:42:44 AM11/21/16
to MIT App Inventor Forum
just try something and if you still have issues, then post a new screenshot of your relevant blocks
see also
Taifun

Abraham Getzler

unread,
Nov 21, 2016, 1:08:46 PM11/21/16
to MIT App Inventor Forum
I need the file to be in following format so I can read the text as tab delimited file on a windows app

 Does your Windows app have the capability to import comma separated values instead of tab delimited values?
That makes things easier on the AI2 side.
If not, you need a way to generate tab (X'09') characters on the AI2 side.
See attached TAB.png for how to do that.

If you are uploading your text file to Windows using the wrong program (NFS) you might be missing the automatic addition of CR (x'0D') to the LF characters.
Windows Notepad might not be satisfied with just NL as an end of line character.
Your Windows app might also need the CRLF sequence,

See my CRLF Gallery sample for blocks to generate CR and TAB.

ABG

TAB.png

SS TheAppInventor

unread,
Nov 22, 2016, 12:10:29 AM11/22/16
to MIT App Inventor Forum
Thanks ABG, the desktop app does have an option to read .CSV file. Do you have any example I can follow to write the 2 textbox field as 2 comma separated values in one line?

Kind regards,
Sal

SPL

unread,
Nov 22, 2016, 3:08:41 AM11/22/16
to mitappinv...@googlegroups.com
I made an app based on your suggestions, but it doesn't add the space between the "'s... Are you interested anyway?

Abraham Getzler

unread,
Nov 22, 2016, 12:15:56 PM11/22/16
to MIT App Inventor Forum
 Do you have any example I can follow to write the 2 textbox field as 2 comma separated values in one line?


 See attached.

It's your sample, with two changes:
  comma instead of space between the two text values, and
  only a single \n

That should work as csv table input.

If your Windows app doesn't like it and wants a CRLF at the end of line,
replace the "\n" at the end of the JOIN with a "call CRLF()" from my sample CRLF app.
ABG

ap2.JPG
Reply all
Reply to author
Forward
0 new messages