LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 10-23-2019, 01:10 PM   #1
jaybiano
LQ Newbie
 
Registered: Oct 2019
Location: New York
Posts: 9

Rep: Reputation: Disabled
Unhappy creating a script that would read in a csv file and output the data in a different format to load into the Lawson payroll system


- this involves creating a Linux script that be run to read in a csv file and output the data in a different format to load into the Lawson payroll system
- the script will be run automatically by skybot whenever an input file is created in a Linux folder.

This is what the CSV look like

Account number (preferred / formatted),Customer reference,Posting date,Account currency,Transaction amount
750856653,233420,3/9/2019,USD,-2092.99
750856653,233417,3/9/2019,USD,-2856.15
750856653,233413,3/9/2019,USD,-1439.58
750856653,233431,3/9/2019,USD,-186.66
750856653,NONREF,3/9/2019,USD,14401.48
750856653,233430,4/9/2019,USD,-320.93
750856653,233427,4/9/2019,USD,-661.9
750856653,233412,4/9/2019,USD,-1888.92
750856653,233428,4/9/2019,USD,-245.71


This is my desired output, i want the account number separated with a hyphen just like that, i want 3 zeros added in front of the customer reference and lastly, the date and transaction amount should be merged to be one. with zeros . Eliminated the USD, initially i had 5 columns, my final result should be just 3 columns.

750-85665-3 0000233420 090319000000209299
750-85665-3 0000233417 090319000000285615
750-85665-3 0000233426 090319000000239225
750-85665-3 0000233414 090319000000173322
750-85665-3 0000233424 090319000000185031
750-85665-3 0000233403 090319000000185032
750-85665-3 0000233413 090319000000143958

MY CODE: (i am confused please help)

#!/bin/bash

input="/file-path/details.csv"


column -t -s: |
sed 's/ ,/,/g'


while IFS=',' read -r f1 f2 f3 f4 f5

do
echo "$f1 $f2 $f3 $f4 $f5 "

done < "$input"
 
Old 10-23-2019, 01:20 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Duplicate of https://www.linuxquestions.org/quest...at-4175663041/

Reported.
 
Old 10-23-2019, 03:10 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to print lines in csv file if 1 csv column field = "text". There are 10 column (;) in csv file nexuslinux Linux - Newbie 9 04-22-2016 11:35 PM
[SOLVED] A challenging script - Replace field of CSV file based on another CSV file arbex5 Programming 11 06-12-2013 06:56 AM
[SOLVED] How to script csv editing? Remove rows from csv file that do not contain certain text ingram87 Linux - Software 9 08-03-2012 12:45 PM
Putty using csv files in BASH to format file in script as output smks Linux - Newbie 7 12-22-2011 05:50 PM
Comparing two csv files and write different record in third CSV file irfanb146 Linux - Newbie 3 06-30-2008 09:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration