How to remove the double quotes in CSV file in iSeries

335 pts.
Tags:
AS400 program
CLLE
CSV
IBM iSeries
Shell commands
Hi The command is to remove the double quotes present in CSV file. I have used one shell command. Strqsh cmd(Sed -e 's/""//g' file name > new file name) I have to write this command in CLLE program. CHGVAR     VAR(&RPLC) VALUE('Sed' *BCAT '-e' *BCAT +                  's/""//g' *BCAT '/' *TCAT &USER +                            *TCAT &WOUTFN *TCAT '_US' *TCAT '_' *TCAT +                &WRKDT *TCAT '.csv' *bcat '>' *bcat   +                    '/' *TCAT &USER *TCAT '/' *TCAT &WOUTFN +                 *TCAT '_US' *TCAT '_' *TCAT &WRKDT *TCAT +                 '.csv')                                        strqsh     cmd(&rplc)       This CHGVAR is throwing eroor.can u pls help me out in framing this command. Thanks

Software/Hardware used:
AS400 clle program

Answer Wiki

Thanks. We'll let you know when a new response is added.

:: remove double quotes
@echo off & setLocal EnableDelayedExpansion
for /f “tokens=* delims= ” %%a in (thefile) do (
set str=%%a
set str=!str:”=!
>> newfile echo !str!
)

Let me know if this works. Robert

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    What error, compile/run on what statement? Strqsh cmd(Sed -e 's/""//g' file name > new file name) CHGVAR VAR(&RPLC) VALUE('Sed' *BCAT '-e' *BCAT + '''s/""//g' Start with this change .. put three single quotes before the s .. - the first ' indicates start string - the pair of single quotes indicate put a single quote here in the output string.
    50,185 pointsBadges:
    report
  • TomLiotta
    Yeah, without knowing the error, there's no way to guess. We don't know the variable definitions, so we can't know what's valid and what isn't. Here's a reformatted version of the statement to help make it readable:
    CHGVAR     VAR(&RPLC) VALUE(
                  'Sed'     *BCAT
                  '-e'      *BCAT +      
                  's/""//g' *BCAT
                  '/'       *TCAT
               &USER   *TCAT +              
               &WOUTFN *TCAT
                  '_US'     *TCAT
                  '_'       *TCAT +  
               &WRKDT  *TCAT
                  '.csv'    *bcat
                  '>'       *bcat   +      
                  '/'       *TCAT
               &USER   *TCAT
                  '/'       *TCAT
               &WOUTFN *TCAT +    
                  '_US'     *TCAT
                  '_'       *TCAT
               &WRKDT *TCAT +    
                  '.csv') 
    There are way too many constants on separate lines. Combining constants to help see what's going on, the statement becomes:
    CHGVAR     VAR(&RPLC) VALUE(
                  'Sed -e s/""//g /'  *TCAT +
               &USER   *TCAT +              
               &WOUTFN *TCAT +
                  '_US_'              *TCAT +
               &WRKDT  *TCAT +
                  '.csv > /'          *tcat +
               &USER   *TCAT +
                  '/'                 *TCAT +
               &WOUTFN *TCAT +
                  '_US_'              *TCAT +
               &WRKDT  *TCAT +    
                  '.csv')
    That's better. It's simplified and much easier to read. It's not correct because it needs "+" signs at the end of some of the lines, but I'm not concerned about that for the moment. Those can be fixed in a minute. Phil's suggestion about adding in the single-quote marks turns it into:
    CHGVAR     VAR(&RPLC) VALUE(
                  'Sed -e ''s/""//g'' /'  *TCAT +
               &USER   *TCAT +              
               &WOUTFN *TCAT +
                  '_US_'              *TCAT +
               &WRKDT  *TCAT +
                  '.csv > /'          *tcat +
               &USER   *TCAT +
                  '/'                 *TCAT +
               &WOUTFN *TCAT +
                  '_US_'              *TCAT +
               &WRKDT  *TCAT +    
                  '.csv')
    This editor tends to mess up single-quotes. I'll paste it normally to help with copy/paste for you: CHGVAR VAR(&RPLC) VALUE( 'Sed -e ''s/""//g'' /' *TCAT + &USER *TCAT + &WOUTFN *TCAT + '_US_' *TCAT + &WRKDT *TCAT + '.csv > /' *tcat + &USER *TCAT + '/' *TCAT + &WOUTFN *TCAT + '_US_' *TCAT + &WRKDT *TCAT + '.csv') At least one additional change I would make is to build the input file name and output file name in separate variables. Trying to construct those two names at the same time the sed command is being constructed makes a mess of everything. The command should look more like this:
    CHGVAR     VAR(&RPLC) VALUE(
                  'Sed -e ''s/""//g'''  *bCAT +
               &inFile  *BCAT +
                  '>'                   *bcat   +      
               &outFile )
    Beyond making it look less confusing, any problems with variable definitions might be isolated to one of the CHGVARs that builds the &inFile or &outFile variables. Don't try to do too much in a single statement. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Oh course, there's the other question, why remove the double quotes from the csv file? If it was created on the 400, it could be created without "" If it will be processed on the 400, it can be processed with "" And if you remove the "" then any test containing a dlimiter (comma?) would be a problem. Phil
    50,185 pointsBadges:
    report
  • Robert2010
    How about this? :: remove double quotes @echo off & setLocal EnableDelayedExpansion for /f "tokens=* delims= " %%a in (thefile) do ( set str=%%a set str=!str:"=! >> newfile echo !str! )
    465 pointsBadges:
    report
  • iiiiiiiiiiiii
    [...] How to remove the double quotes in CSV file in iSeries [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following