Xk6-file - does it support to delete a row from csv file?

I am using the xk6-file and it is working fine with file read and write… but I want to delete the same already used data, so how to do that …

Hi @subbun,
I see an open issue with the same question in the repo: how to delete a row using the xk6-file? is it supports? · Issue #3 · avitalique/xk6-file · GitHub

I don’t see any code supporting your case so I think you could consider contributing and open a pull request for it, xk6-file is a community extension so k6 doesn’t maintain it directly.

I can try to post some code suggestions but can you please explain with more accuracy what you’re trying to delete? Could be an option to rewrite the file when you already processed the entire file?

1 Like

Try looking at this example and ideally raise a PR for this.

https://www.rosettacode.org/wiki/Remove_lines_from_a_file

@codebien Once the lined is used from the csv I want to delete that entire line from my csv file after.

ex: csv.
username,password,createdUniqueID
test1,password,3434343
test1,password,3643422
test2,password,9343433
test3,password,8534343

so above cretaedUniqueID, once I used it then I can not repeat in my script for next iteration, so I want to delete it once it is used after request.

Hi @subbun,
what is the size of the CSV file? In the case it isn’t a big file you could evaluate using the SharedArray for loading the dataset in memory. Check this section of the Data parametrization example and this other section for iterating the SharedArray for retrieving unique items.

Let me know if it helps.

@codebien thanks for update, I can get the Unique values … this is the issue… I want to delete the used row from CSV. how to do that…

Hi @subbun,
as I said in the first message this case is not covered by the currently available solutions for that reason I provided some alternatives.

I see that the maintainer of the extension asking for details on the issue, you should consider explaining there, in detail, your use case.

As a note, it could be useful to know that writing a file for each iteration could be an intensive operation impacting the performance of your load testing system.