[Çözüldü] awk komutu ile csv manipülasyonu

Başlatan shigej38, 20 Ağustos 2019 - 15:27:57

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

shigej38

merhabalar arkadaşlar csv dosyalarının iki sütününü birleştirip tekrar aynı csv dosyasının birinci sütününa yazan bir betik yazdım ancak şu şekilde bi hata alıyorum.

almış olduğum hata
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157333.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157397.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157412.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157482.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157524.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157531.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157570.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/157577.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/162713.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/171445.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/172719.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/172764.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/172765.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/172766.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/172767.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/172802.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/filtered_merged_157680.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/filtered_merged_167335.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/filtered_merged_167344.csv' for reading (No such file or directory)
awk: fatal: cannot open file `/home/detagen/Desktop/result/input/merged_157680.csv' for reading (No such file or directory)





betiğim

#!/bin/bash

PG=/home/$USER/Desktop/programlar
RESULT=/home/$USER/Desktop/result
IN=$RESULT/input
OUT=$RESULT/output

cd $IN

for FILE in `ls -v *_.csv`; do
BASE=${FILE%%_.csv}
if ! [ -d $OUT/$BASE ]; then
mkdir $OUT/$BASE
fi
cd $IN
awk '{print $8,$6,"\t", $0}' $IN/$BASE.csv > $OUT/$BASE/$BASE.csv

done



Mesaj tekrarı yüzünden mesajınız birleştirildi. Bu mesajın gönderim tarihi : 20 Ağustos 2019 - 15:37:43

arkadaşlar rastgele deneme yaparken çözümü buldum.

for döngüsü içerisinde ki
awk '{print $8,$6,"\t", $0}' $IN/$BASE.csv > $OUT/$BASE/$BASE.csv

satırını şu şekilde düzenledim
awk {'print $8,$6,"\t", $0'} $IN/$FILE > $OUT/$BASE/$BASE.csv

bu şekilde yapınca dosyaları rahat bir şekilde işledi.

Empat

[mention=648769]@shigej38[/mention]
Merhaba.

Çözümü paylaştığınız için teşekkürler.

Lütfen kısa süre içerisinde üst üste ileti (flood) atmayın.

Bunun yerine daha önce attığınız iletiyi düzenleyin.
Everything for me is just Peace - Love - Coding. Also, as they say: I am a programmer, I have no life!