Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Export Fields as RAW / ASCII Text
Tagged: export
- This topic has 8 replies, 3 voices, and was last updated 3 years, 7 months ago by Sam Moffatt.
-
AuthorPosts
-
May 9, 2021 at 8:32 AM #44335
DrJJWMacParticipantI am creating a database with text fields. I want to export the data records as the equivalent to raw, ASCII text. I do not want the quotation marks around the text and I want the “\r” (carriage return) character to expand properly.
How can I accomplish this?
I am conversant enough in the JavaScript to use that method if needed.
—
JJWMay 9, 2021 at 10:16 PM #44338
Sam MoffattParticipantThe CSV export will likely wrap things in quotes for compatibility reasons, I don’t believe there is a way I’ve seen to turn it off.
You could easily create a form script that generates the output via
console.log
that you could easily grab out of the display, something like:for (let record of form.getRecords()) { console.log(record.getFieldValue('fld-yourfieldid')); }
Would do the trick to dump out all of the records to the console for you. Replace the
fld-yourfieldid
with the field ID you care about, you can get the field ID by double clicking on the field you want in the script editor or from underneath the field description in the field editor.May 10, 2021 at 9:23 AM #44342
DrJJWMacParticipantThank you.
Two things then. First, would you have a recommendation on how to dump the output directly to a file?
Second, let me use this opportunity to put in a request for a RAW/TEXT option for exporting records.
May 10, 2021 at 10:07 PM #44350
Sam MoffattParticipantThere isn’t a way to write a file directly, if I was to put it straight to a file I would send it to a web service and use that to dump it to disk for me. You can use
Utils.postContentToUrlWithContentType()
orUtils.postJsonToUrl()
to call out to a web service. Probably for your use casepostContentToUrlWithContentType
with a simple text content would suffice. They’re pretty simple API’s with details on the Javascript page.Something like this should work:
let entries = []; for (let record of form.getRecords()) { entries.append(record.getFieldValue('fld-yourfieldid')); } Utils.postContentToUrlWithContentType(entries.join("\n"), "http://localhost/tapforms-bridge.php", "text/plain");
Then
tapforms-bridge.php
could look like this:<?php file_put_contents("/tmp/file.txt", file_get_contents("php://input"));
As a simple example of getting data out, it’s not the greatest solution but it should do the trick. You’d need to get the built in Apache and PHP set up on your Mac but there are plenty of guides out there for that.
May 11, 2021 at 8:14 AM #44356
DrJJWMacParticipantThank you again.
I am beginning to think that an easier alternative will be to export as CSV and then run a converter (AppleScript or other) to massage the CSV to raw.
FWIW, my objective is to use TapForms as a front end GUI to a database of LaTeX-encoded problems. An example record output would appear as below.
\begin{defproblem}{enthalpy-phasetransitionenthalpy-default}
From the attached plot, what is the molar enthalpy $\Delta_{vap}\bar{H}$ to heat the room?\smallskip
\putfig[0.1\textwidth]{fig-enthalpyplot}
\end{defproblem}I can set fields for the topic (enthalpy), problem (phase transition enthalpy), set (button choices from A … example, default), LaTeX problem (From the attached plot …), has figure (yes/no), figure name (enthalpyplot), and relative figure size (0.1). A JavaScript field builds the final output from the data form. I intend to use this to administer sets of problems in a topic to track across exams, homework, and examples. I can build the exam or homework questions and then add examples (eventually with answers) to assure that students have seen what I will test against. The raw outputs for any cases are compiled into a final document using a LaTeX package called probsoln.
In closing, I will use this thread once more to request a RAW/ASCII export option either directly or through JavaScript.
—
JJWMay 11, 2021 at 12:37 PM #44358
BrendanKeymasterIt would be good to have some cover methods to let you write directly to the file system from JavaScript.
May 11, 2021 at 6:56 PM #44360
DrJJWMacParticipantAn alternative would be to have a checkbox in the export dialog box that would say the equivalent of
[ ] strip quotation marks from output
Thanks for the consideration. I am glad to be back to Tap Forms with this potential use after a few years on other ventures. The app was and remains quite nice to use.
—-
JJWMay 11, 2021 at 10:17 PM #44364
BrendanKeymasterYes, an extra option to include or exclude quotes is also a thing I could add. Will consider it for a future version. Thanks for the feature request.
May 12, 2021 at 10:36 PM #44372
Sam MoffattParticipantOne other way to get to your data could be to go through the CouchDB API but that’s probably more work than its worth. You don’t necessarily need to set up a CouchDB server to try it out, you can use the local Nearby sync port to get access to the data leveraging a DNS-SD Browser to find it.
-
AuthorPosts
You must be logged in to reply to this topic.