Click here to Skip to main content
15,071,729 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have no c# or visual basic experience and I am looking for some C# or visual basic code to sort through a csv file and compiles txt files depending on values in the csv file, this can be done using a console app or anything else, as long as it just writes the txt files and gives the correct output.

The input file (CSV File) contains multiple records, each with multiple fields, delimited by commas
Field             Description
accountholder     -First name and Surname of the account holder
accountnumber     -Account number that needs to be debited
accounttype       -Type of account that needs to be debited
bankname          -Bank where the account is held
branch            -Brach where the account is held
amount            -Amount that needs to be debited, in rand and cent
date              -Date that debit needs to happen (mm/dd/yyyy)

Each output file should be the bank name, it should sort the rows in the csv according to the bank and output them into the txt for that bank, if one does not exist it should create it.

Every file will have a single line at the top, a header record, summarizing the data in the file. The header record will have the following data in one long string.

Below is an example header for Beep Bank with 100 records to the value of $90998.10.

BEEP BANK 1000009099810

Element           Description                                              Pad char     Pad side       Length
Bank name      First 16 characters of the Bank name      [space]      right              16
                       as per file name, padded with spaces
                       at the end if the name is less than
                       16 characters long. Convert to
                       Uppercase
Record count   Number of data records in the file,           0                left                3
                        depicted as a 3 character,
                        zero-left padded string
Total value       Value (in cents) of all amounts in             0                left                10
                        the file, depicted as a  10 character,
                        zero-left-padded string

Total Header Record Length = 29

The detail records will be constructed as below. Given this, it can be deduced that every detail record will be the same length.

Here is an example detail record to deduct $100.72 on 31 December 2012 from Maria Smith’s Credit Card, account number 123456 for the branch in Durban.
MSmith, 123456,CC, BankName,Durban,0010072,31201212;

Element           Description                                                           Pad char Pad side Length
Initials             First initial of account holder, depicted as a          n/a          n/a        1
                       single character
Surname      Surname (spaces removed) of the account holder   [space]    right     15
                    depicted as a 15 character, space-right-padded
                    string.All spaces to be removed from surnames
                    like "Le Roux" before padding.
AccountNr    Account number to be debited, depicted as a 14     [space]    right     14
                    character, space-right-padded string
Account Type A mnemonic/abbreviation for the account type       [space]    right     3
                    depicted as a 3 character, space-right padded
                    string using these lookups:
                       oCH = Cheque account
                       oSAV = Savings account
                       oCR = Credit card
                       oOTH = Any other account type
Branch        Branch name where account is held, depicted as      [space]    right     10
                   a 10 character, space-right-padded string
Amount       Amount, in cents,  to be deducted from account,       0              left       7
                   depicted as a 7 character, zero-left-padded string
Date            Debit date depicted as a 8 character string               n/a          n/a       8
                   representing the date in the format ddyyyymm

Total Detail Record Length = 58


Detail records shall be sorted below the header in the file. Records are to be sorted in ascending order based on the amount, and then in ascending order based on the Account Holder’s surname. So where two records of the same amount is found, these records must be sorted based on the surname of the account holder.

The file should end with a CRLF (Carriage return line feed) after the final record.

I would also like to try and show the progress of processing the csv and give a summary of the files produced with values and counts

I will appreciate any input

Thanks in advance
Posted
Updated 20-Nov-14 4:12am
v2
Comments
Sinisa Hajnal 20-Nov-14 9:07am
   
How much do you offer for the code? :)

Note that questions should be focused on single problem, not general advice on how to do something (you can google that) or request that others do something for you. This is NOT free-code-service.
BillWoodruff 20-Nov-14 9:59am
   
Hire a programmer.

Hello Member,

How about using FileHelpers[^] Library to read the CSV file. You can then dump this data to any database and query the database with desired sort order and ouput a file again using FileHelpers.

Regards,
   
You say "I have no c# or visual basic experience and I am looking for some C# or visual basic code..." - you expect someone has code for your exact requirenment arround? So start learning how to programm or hire a programmer - you know what you want, now someone has to code it - if you are willing to pay I could do it... :-)
   
Tons of examples you'll find via using SearchBox[^] at the right-top corner of this site.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900