ich eine CSV-Datei des Formulars haben:Splitting CSV-Datei in Textdateien
1,frog
2,truck
3,truck
4,deer
5,automobile
und so weiter, für etwa 50 000 Einträge. Ich mag 50 000 getrennte TXT-Dateien mit der Zahl vor dem Komma und mit dem Wort nach dem Komma, wie so genannt, erstellen:
1.txt contains: frog
2.txt contains: truck
3.txt contains: truck
4.txt contains: deer
5.txt contains: automobile
und so weiter.
Dies ist das Skript, das ich bisher geschrieben habe, aber es nicht richtig funktioniert:
#!/bin/bash
folder=/home/data/cifar10
for file in $(find "$folder" -type f -iname "*.csv")
do
name=$(basename "$file" .txt)
while read -r tag line; do
printf '%s\n' "$line" >"$tag".txt
done <"$file"
rm "$file"
done
Danke, weiß nicht, wie ich das nicht gesehen haben. – Qubix