Add two delimiters after every sixth comma

 If you want to add two delimiters (for example, commas) after every sixth comma in a string, you can achieve this using a simple Python script. Here's a basic example:


```python

input_string = "data1,data2,data3,data4,data5,data6,data7,data8,data9,data10,data11,data12"


# Split the input string by comma

parts = input_string.split(',')


# Define the number of elements between the added delimiters

elements_between_delimiters = 6


# Initialize an output string

output_string = ""


# Iterate through the parts and add two delimiters after every sixth comma

for i, part in enumerate(parts):

    output_string += part

    if (i + 1) % elements_between_delimiters == 0:

        output_string += ",,"  # Add two commas

    else:

        output_string += ","  # Add a single comma


print(output_string)

```


This code will take the input string, split it by commas, and then add two commas after every sixth comma. You can adjust the `elements_between_delimiters` variable to specify a different number of elements between the added delimiters if needed.

Comments

Popular posts from this blog

bad character U+002D '-' in my helm template

GitLab pipeline stopped working with invalid yaml error

How do I add a printer in OpenSUSE which is being shared by a CUPS print server?