Question: Using this code I have write/replace data in an excel file. But now i need to do the same thing for csv file. Can someone help me with that?

```py
with pd.ExcelWriter('2.xlsx', mode='a', engine='openpyxl', if_sheet_exists='replace') as writer:  
    fm_data.to_excel(writer, sheet_name='Raw Data1') 

```

Answer: 
Assuming you know there are only 2 columns *and* the second column is always a floating-point number (when there are any), you can use this:

```
awk -F, 'NF == 3 { $0 = $1FS$2"."$3 } NF == 4 { $0 = $1"."$2FS$3"."$4 } 1' infile

```
You could easily do this tsk in `awk`. Please try following code written and tested in GNU `awk`.

```
awk '
BEGIN{ FS=OFS="," }
NF==3{
  match($0,/(^[^,]*),([^,]*),(.*$)/,arr)
  print arr[1],arr[2]"."arr[3]
  next
}
NF==4{
  match($0,/(^[^,]*),([^,]*),([^,]*),(.*)$/,arr)
  print arr[1]"."arr[2],arr[3]"."arr[4]
}
'   Input_file

```

***NOTE:*** In case you want to save output into `Input_file` itself then append  `> temp && mv temp Input_file` to above code.

***Explanation:*** Adding detailed explanation for above `awk` code.

```
awk '                                            ##Starting awk program from here.
BEGIN{ FS=OFS="," }                              ##Setting FS and OFS as comma in BEGIN section of this awk program.
NF==3{                                           ##Checking if there are 3 number of fields in current line then do following.
  match($0,/(^[^,]*),([^,]*),(.*$)/,arr)         ##Using match to match regex (^[^,]*),([^,]*),(.*$) to create 3 capturing group to be saved into arr array.
  print arr[1],arr[2]"."arr[3]                   ##Printing 1st element of arr followed by comma followed by 2nd element followed by DOT followed by 3rd element of arr.
  next                                           ##next will skip all further statements from here.
}
NF==4{                                           ##Checking if there are 4 number of fields in current line then do following.
  match($0,/(^[^,]*),([^,]*),([^,]*),(.*)$/,arr) ##Using match to match regex (^[^,]*),([^,]*),([^,]*),(.*)$ to create 4 capturing group to be saved into arr array.
  print arr[1]"."arr[2],arr[3]"."arr[4]          ##Printing 1st element of arr followed by dot followed by 2nd element followed by comma followed by 3rd element of arr, followed by DOT followed by 4th element of arr.
}
'  Input_file                                    ##Mentioning Input_file name here.

```