How to convert python script to groovy script?

import time

import os
import datetime

from glob import glob

from pathlib import Path
import csv
from time import gmtime, strftime

file = “C:/Users/Rout.Bikram/Desktop/PYTHONCODESAMPLE/nyc_taxi_data.csv”

FILENAME =Path(‘C:/Users/Rout.Bikram/Desktop/PYTHONCODESAMPLE/nyc_taxi_data.csv’).stem

a = “”
b = “”
recordSeparator = “LF”
padding_size = 4

Code to pad spaces in recordSeparator string

rcrdSep = recordSeparator + " "*(padding_size - len(recordSeparator))

charSpaceEncode = “EBCDIC”
padding_size = 8

Code to pad spaces in a charSpaceEncode string

charSpcEncd = charSpaceEncode + " "*(padding_size - len(charSpaceEncode))

charSetEncoding = “277”
padding_size = 20

Code to pad spaces in a charSpaceEncode string

charSetEncd = charSetEncoding + " "*(padding_size - len(charSetEncoding))

header=""
padding_size = 15

Code to pad spaces in a charSpaceEncode string

headerDecl = header + " "*(padding_size - len(header))

timeZone = strftime("%z", gmtime())
padding_size = 6

Code to pad spaces in a charSpaceEncode string

tmZone = timeZone + " "*(padding_size - len(timeZone))

businessProductionDate = datetime.datetime.fromtimestamp(os.path.getctime(file)).strftime(’%y%y-%m-%d’)
padding_size = 10

Code to pad spaces in a charSpaceEncode string

businessPrdDate = businessProductionDate + " "*(padding_size - len(businessProductionDate))

creationDateTime = datetime.datetime.fromtimestamp(os.path.getctime(file))
DateTime = str(creationDateTime)
padding_size = 32

Code to pad spaces in a charSpaceEncode string

CreationDTTZ = DateTime + " "*(padding_size - len(DateTime))

generatedBy = “FOUNDRY”
padding_size = 50

Code to pad spaces in a charSpaceEncode string

generatedbySource = generatedBy + " "*(padding_size - len(generatedBy))

sourceCompany = “DNB”
padding_size = 50

Code to pad spaces in a charSpaceEncode string

srcCompany = sourceCompany + " "*(padding_size - len(sourceCompany))

routineNum = “1599”
padding_size = 20

Code to pad spaces in a charSpaceEncode string

projRoutineNum = routineNum + " "*(padding_size - len(routineNum))

schemaName = “SCHEMANAME”
padding_size = 30

Code to pad spaces in a charSpaceEncode string

schmName = schemaName + " "*(padding_size - len(schemaName))

sourceFileName = FILENAME
padding_size = 254

Code to pad spaces in a charSpaceEncode string

srcFileName = sourceFileName + " "*(padding_size - len(sourceFileName))

def insertChar(mystring, position, chartoinsert ):

mystring   =  mystring[:position] + chartoinsert + mystring[position:] 
return mystring   

SETTING THE HEADER FOR THE FILE

s1=insertChar(a,1, ‘0’)

s2 = insertChar(s1,2, ‘|’)

s3 = insertChar(s2,3,rcrdSep)

s4 = insertChar(s3,7, charSpcEncd)

s5 = insertChar(s4,15,charSetEncd)

s6 = insertChar(s5,35,headerDecl)

s7 = insertChar(s6,50,tmZone)

s8 = insertChar(s7,56, businessPrdDate)
s9 = insertChar(s8,66, CreationDTTZ)

s10 = insertChar(s9,98, generatedbySource)

s11 = insertChar(s10,148, srcCompany)

s12 = insertChar(s11,198, projRoutineNum)
s13 = insertChar(s12,218, schmName)

s14 = insertChar(s13,248, srcFileName)
s15 = insertChar(s14,502, ’ ')

Header = s15

print(Header)

SETTING THE FOOTER FOR THE FILE

fileNum = open(“C:/Users/Rout.Bikram/Desktop/PYTHONCODESAMPLE/nyc_taxi_data.csv”)

numline = len(fileNum.readlines()) -1
recordCount = str(numline)

padding_size = 15

Code to pad spaces in a charSpaceEncode string

recordCnt = recordCount + " "*(padding_size - len(recordCount))

s1=insertChar(b,1, ‘2’)

s2 = insertChar(s1,2, ‘|’)

s3 = insertChar(s2,3, rcrdSep)

s4 = insertChar(s3,7, charSpcEncd)

s5 = insertChar(s4,15,charSetEncd)

s6 = insertChar(s5,35,recordCnt)

s7 = insertChar(s6,50,tmZone)
s8 = insertChar(s7,56, businessPrdDate)
s9 = insertChar(s8,66, CreationDTTZ)
s9 = insertChar(s8,66, CreationDTTZ)

s10 = insertChar(s9,98, generatedbySource)

s11 = insertChar(s10,148, srcCompany)

s12 = insertChar(s11,198, projRoutineNum)
s13 = insertChar(s12,218, schmName)

s14 = insertChar(s13,248, srcFileName)
s15 = insertChar(s14,502, ’ ')

Footer = s15

print(Footer)

file1=open(“C:/Users/Rout.Bikram/Desktop/PYTHONCODESAMPLE/nyc_taxi_data.csv”,“r”)

with open(“C:/Users/Rout.Bikram/Desktop/PYTHONCODESAMPLE/New.csv”, “w”) as file:
file.write(Header)
next(file1)
file.write(’\n’)

for line in file1:
      file.write('1|' + line.replace(',', '|'))

file.write('\n')
file.write(Footer)    

file1.close()

When you paste code you can select all of it and use the </> icon to format it as code, then it is better human readable.

Otherwise if you would give some description what you are trying to do and for what purpose then we possibly could give you some answer.