split file

This is a discussion on split file within the C Programming forums, part of the General Programming Boards category; Good day, I need help from you. I have to split and create output files by every 30.000 recordings. Example ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    2

    split file

    Good day,

    I need help from you.

    I have to split and create output files by every 30.000 recordings.
    Example ,

    Input file has 150.000 (transaction.txt) recordings of bank accounts transactions.
    The C code has to split this file and create output files by 30.000 records each from input file.
    (transaction1.txt, transaction2.txt, transaction3.txt and etc.).The transaction.txt (150.000 recordings) has to be split on many files with 30.000 recordings.
    So , does anybody know how to do this?
    How C code will look like for this operation?

    Thank you very much.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    2
    Please see how Account.txt file looks.

    07004262890147655236 74105616281002275393260000000001007000000002000428 000000002000428LHZB ATMH0418 - Limbaz Limbazi LV 6011 1009N3049252 2 6282
    0701 000000 00002 5904180 ATMH0418000000000000 000000 00 000000000
    07004389380039629638 74105616281002275394193000000001007000000015000428 000000015000428LHZB ATMH0401 - Elizab Riga LV 6011 1009N2084002 2 6282
    0701 000000 00002 5904016 ATMH0401000000000000 000000 00 000000000
    07004262890148616575 74105616281002275257663000000001007000000002000428 000000002000428LHZB ATMH0422 - Aizkra Aizkraukle LV 6011 1009N2201432 2 6282
    0701 000000 00002 5904222 ATMH0422000000000000 000000 00 000000000
    07004262890146321046 74105616281002275252417000000001007000000010000428 000000010000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N3462742 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004262890146321046 74105616281002275252409000000001007000000002000428 000000002000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N3369872 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004262890144868220 74105616281002275252391000000001007000000002000428 000000002000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N3123242 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004262890147233141 74105616281002275252342000000001007000000001000428 000000001000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N2373252 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004262890146395032 74105616281002275252300000000001007000000001000428 000000001000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N2273262 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004262890146802094 74105616281002275252292000000001007000000005000428 000000005000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N2232802 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004262890144868220 74105616281002275252326000000001007000000003000428 000000003000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N2325232 2 6282
    0701 000000 00002 5904339 ATMH0433000000000000 000000 00 000000000
    07004389380039446967 74105616281002275252334000000001007000000005000428 000000005000428LHZB ATMH0433 - Kudras Riga LV 6011 1009N2355882 2 6282
    0701 000000 00002

  3. #3
    The C eater *munch*
    Join Date
    Oct 2006
    Posts
    101
    what have you done so far? use fopen if you want to open the file, put the content into a buffer, and save it per 30000 byte using loop....

    that's if you want the hint...

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You could just open the input and output files, and write 30,000 (or is that 30?) "recordings" to the output file. Then just close the output file and open the next one. Keep doing this until there's no more data in the input file.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Is there an echo echo echo in here?
    http://www.tek-tips.com/viewthread.c...1291261&page=1
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File being filled with NULLs
    By Tigers! in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2009, 05:28 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 09:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21