Wie konvertiert man Klartextdateien in libreoffice cal (Excel-Arbeitsblatt) auf Ubuntu 14.04?

389
user1946440

Ich habe eine reine Textdatei, die sehr viele Daten enthält. Die Daten werden durch Semikolon und eine neue Zeile zum Beginn einer neuen Zeile der folgenden Daten getrennt. Hier ist ein Beispiel:

"user_id"; "device_id"; "timestamp"; "driving"; "id"; "onfootoptional"; "running"; "servertimestamp"; "stationär"; "tiltingoptional"; "unknown"; "walking"

2089; 2145; "2016-01-28 14:31:27"; 28; "b28aa64d-7fe0-49e7-8a1b-b8d37c95a851"; 1; 0; "2016-01-28 15:11:41"; 18; 0; 50; 1

Ich habe versucht, mit der allgemeinen Methode zu konvertieren und nicht zu konvertieren. Das Problem, das ich nach der Konvertierung finde, ist die Ausgabe in chinesischen Buchstaben, während der Text nur englische Buchstaben und Zahlen mit einigen Sonderzeichen enthält. Auch die Konvertierung folgt nicht als Textdatei, wie wenn eine neue Zeile kommt, sie soll von einer neuen Zeile ausgehen.

Wie ich Textdateien wirklich in Excel-Tabelle konvertieren möchte, ist:

  1. Wandeln Sie jeden Abschnitt, der " etwas oder nichts " enthält, gefolgt von einem " ; " in eine einzelne Zelle um.

  2. Wenn es sich im Feld "" um einen String handelt, muss er als String konvertiert werden. Wenn er nur Integer-Zahlen enthält, muss er als Integer-Nummer konvertiert werden. Wenn es jedoch eine Mischung aus Zeichenfolge und Ganzzahl gibt, muss diese als Zeichenfolge konvertiert werden. Wenn eine Ganzzahl einen Typ von Sonderzeichen wie ".", ",", "-" oder ":" enthält, muss diese zusätzlich als Ganzzahl plus Sonderzeichen konvertiert werden.

  3. Wenn die Textzeile mit einer neuen Zeile abgeschlossen ist, beginnt die Konvertierung auf der Excel- Tabelle mit einer neuen Zeile.
1
Was ist die "allgemeine Methode" - was haben Sie speziell versucht? Jim K vor 8 Jahren 0

3 Antworten auf die Frage

0
nox

I think, the built-in function (is this the general method?) of Libreoffice should be able to do this?
If not - try csv2odf. This is a very handy tool, especially for many files to convert. It should fit your needs.
I am not sure about the formatting you mentioned. Give csv2odf a try. If it does not what you want it to do, try to specify, what csv2odf does
-you want
-you don't want

Best with proper examples.

Hope this helps. Good luck!

0
Jim K

I copied and pasted your sample into a file called "test.csv" and then double-clicked on it. Using the default settings, it opened just fine in Calc.

Try trimming down the file to a few hundred rows using a text editor, and then open it. If that works, then it should give an idea of what is causing the problem.

Maybe the file has newline problems. Try fixing them like this: https://unix.stackexchange.com/questions/32954/use-sed-to-fix-broken-newlines

Also check the encoding: https://stackoverflow.com/questions/805418/how-to-find-encoding-of-a-file-in-unix-via-scripts

If "huge amount of data" is over 1 million rows, see https://ask.libreoffice.org/en/question/8631/upper-limit-to-number-of-rows-in-calc/.

0
user1946440

The problem is solved. The conversion is not working correctly on my laptop but on someone else's Ubuntu 14.04 it worked. He basically didn't change any setting while converting. He has just followed by clicking next and then Ok finally.

Thanks for your responses.