I have the following file in the S3 bucket:
field1;field2;field3
VAL11,VAL12;VAL13
VAL21,VAL22;VAL23
VAL31,VAL32;VAL33
The final goal is to remove only the first line of the file field1;field2;field3
. This is the desired result:
VAL11,VAL12;VAL13
VAL21,VAL22;VAL23
VAL31,VAL32;VAL33
For the moment I have the following function that is reading all the content form the file. And breaking down using \n
, removing the first line and then concatenating all again using \n
.
So is there a way to remove this first line without breaking down and assembling again?
async function createRef (version,FIRMWARE_BUCKET_NAME) {
const refFile = version + '/ref.ref'
const ref = await getObject(FIRMWARE_BUCKET_NAME, refFile)
const refString = ref.toString('utf8')
let arrRef = refString.split('\n')
arrRef.shift()
let refConcatenated=''
for (let i = 0; i < arrRef.length; i++) {
if (arrRef[i] !== '' ) {
let line = arrRef[i]
refConcatenated = refConcatenated + line + '\n'
}
}
return refConcatenated
}