Unify CSV & JSON uploads for Ngrams
Hopefully fixes #287 (closed).
This MR modifies the implementation of the /api/v1.0/lists/:id/csv/add/form/async
endpoint to internally parse the input CSV into an NgramList
type so that we can call the postAsyncJSON
function, effectively reusing code and implementing form uploads with a single function rather than two distinct ones.
@anoe This should eventually pass CI and the tests. There are important aspects to consider, none of which is related to this MR, but this is the way the CSV endpoint worked even before:
-
There is a loss of information between a CSV import/export and a JSON import/exports. In a CSV (or, I should say, TSV) file, all we can represent are terms, which means we cannot export or import things like authors, docs etc. like we can do with JSON;
-
In a standard JSON import/export, we can store the
size
into anNgramsRepoElement
. However, when we import/export using TSVs, we lose this information, which means that all the imported elements will have asize
of 1.
At this point let me know if you hit the original bug where the number of imported entries from your TSV file didn't match the total rows of the file and we will have a proper look.