I have this string in particular:
123,abc,true,true,true,false,true,false,false,false,123,"my name is : something('Jack'), email is 'abc@gmail.com' is already provided. The company's policy 'xyz', is beneficial.",ABCD,591633,1
I want to split the string by commas by excluding the commas inside the Double Quotes. So the Output that I am trying to produce here is
[123, abc, true, true, true, false, true, false, false, false, 123, "my name is : something('Jack') email is 'abc@gmail.com' is already provided. The company's policy 'xyz' is beneficial.", ABCD, 591633, 1]
I have tried using other stackoverflow post's answers, but they DID NOT work for such string. Can anyone help me on how I can achieve this?
I'm trying to implement this in Kotlin.
One way I could think to get this is, first getting rid of commas inside the double quotes and then splitting the string by commas, but couldn't get the expected result.
Since you're trying to parse a CSV file, it's almost always far better to use an existing library than to write your own code. Advantages include:
One example is Apache Commons CSV, which is free, open-source, and trivially easy to include in any Maven or Gradle project.