Büyük bir Metin Dosyası Bölmek için kolay bir Yolu? | Netgez.com
SORU
6 Ocak 2010, ÇARŞAMBA


Büyük bir Metin Dosyası Bölmek için kolay bir Yolu?

Ayrıca satır sayısı ile daha küçük dosyalara bölmek istiyorum (satır sayısı) büyük bir düz metin dosyası var. Eğer öyleyse benim dosya var etrafında 2M hatları isterim bölme içine 10 içeren dosyalar 200 k çizgiler veya 100 içeren dosyalar 20k hatları (artı bir dosya ile kalanı; olmak bölünebilen eşit önemi yok).

Ben bunu oldukça kolay Python ama merak ediyorum eğer orada herhangi bir ninja yolu bunu yapmak için kullanan bash, unix araçlarının (karşıt olarak el ile döngü ve sayma / bölümleme satır).

CEVAP
6 Ocak 2010, ÇARŞAMBA


Baktı split komutu var mı?

$ split --help
Usage: split [OPTION] [INPUT [PREFIX]]
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
size is 1000 lines, and default PREFIX is `x'.  With no INPUT, or when INPUT
is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -a, --suffix-length=N   use suffixes of length N (default 2)
  -b, --bytes=SIZE        put SIZE bytes per output file
  -C, --line-bytes=SIZE   put at most SIZE bytes of lines per output file
  -d, --numeric-suffixes  use numeric suffixes instead of alphabetic
  -l, --lines=NUMBER      put NUMBER lines per output file
      --verbose           print a diagnostic to standard error just
                            before each output file is opened
      --help     display this help and exit
      --version  output version information and exit

Gibi bir ÅŸey yapabilirsin:

split -l 200000 filename

Bunu PaylaÅŸ:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 24 Канал

    24 КанаÐ

    5 ÅžUBAT 2006
  • Learn Math Tutorials

    Learn Math T

    20 Kasım 2011
  • Nickcidious

    Nickcidious

    6 HAZİRAN 2011