First of all, I am using the Feather MO Adalogger from Adafruit with the Ultimate GPS Feather hat to collect some GPS data: time stamp (millisec), GPS Coordinates (latitude & longitude), speed (knots), and altitude (meters). The GPS data is stored on a micro SD card and I have the GPS portion of the code working. The data I want is being stored on the micro SD card. My only problem is that I can't get the data to be appropriately put in columns under their respective "headers". I used .print("\t") after each data type in attempt to tab the data into columns. This worked for the "headers" but not for the data itself. Screenshots and code are below. Thanks in advance!

My txt file: Headers

Headers in my txt file

My text file: working GPS data Data in my txt file

Code for Headers headers code

Code for data data code

  • 4
    Don't post sketch images; post the sketch itself, so others can copy-paste them for testing. – user31481 Nov 24 '17 at 22:19
  • 2
    Please edit your question to include a Minimal, Complete, and Verifiable example of code, not just snippets. Minimal means you've stripped away irrelevant stuff, just leaving what's needed to show the problem. Complete means all the library names are shown, all the variable declarations, and all the function definitions – so people don't have to waste time guessing what you did or what you meant. Verifiable means it can be compiled and tested, allowing other people to test their theories about the problem – user31481 Nov 24 '17 at 22:19
  • The tab '\t' has no fixed number of positions. It can be every 2 or every 8 or anything else. You can try to fill up with spaces. For example the sprintf function can do that. Are you sure you want to show the text file nicely formatted under the headers? It is more common to use the text file as data for visualization tools. – Jot Nov 24 '17 at 22:22
  • @Jot I just want my data to be easily copy/pasted into a data manipulation/graphing program like excel or matlab. Any suggestions on how to do that? I copied the data the way it is but it pastes awkwardly into excel. Thanks btw – user52619 Nov 24 '17 at 22:25
  • @user52619 And we want easily copy/pasteable code for testing. – gre_gor Nov 25 '17 at 4:39

Change the println()s to print()s. Put one println() at the end of the list of data prints. You want each row of data to not take up more than one line in the text file. A println() starts a new row after printing.

Also, you’ll want to open the text file in a tabular program like Excel or similar. A plain text editor likely won’t utilize tab characters in the way you like.

| improve this answer | |
  • Thank you so much!! That worked perfectly just how I wanted! (: – user52619 Nov 24 '17 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.