Saturday, May 6, 2023

vlsub not working solved

opensubtitles API has changed its request format from XML to JSON only. In adiction it also needs a session token to validate requests. So, in a few words, VLSub needs a re-work to replace the old function, to call the API with a valid token and process JSON data.

EDIT: But, there's a workarround for this. As the previous version of opensubtitles is still working, you can edit your system hosts file to route VLSub call as XML. The default path of the hosts file in Windows 10 appears to be C:\Windows\System32\drivers\etc and you have to open your text editor as admin to edit the file. Add a new line and type 104.25.132.104 api.opensubtitles.org Save hosts file and try VLSub again. NOTE: This is valid while XML service is active in the old API address.



Friday, April 7, 2023

Some common usages of cat command

1) To view a single file 
Command: 
 

$cat filename

Output 
 

It will show content of given filename

 

2) To view multiple files 
Command: 

 

 

$cat file1 file2

Output 
 

This will show the content of file1 and file2.

 

 

3) To view contents of a file preceding with line numbers. 
Command: 
 

$cat -n filename

Output 
 

It will show content with line number
example:-cat -n  geeks.txt
 
1)This is geeks
2)A unique array

 

4) Create a file 
Command: 
 

$ cat > newfile

Output 
 

Will create a file named newfile

 

5) Copy the contents of one file to another file. 
Command: 
 

$cat [filename-whose-contents-is-to-be-copied] > [destination-filename]

Output 
 

The content will be copied in destination file

 

6) Cat command can append the contents of one file to the end of another file. 
Command: 
 

$cat file1 >> file2

Output 
 

Will append the contents of one file to the end of another file
 

7) Cat command can display content in reverse order using tac command. 
Command: 
 

 $tac filename

Output 
 

Will display content in reverse order 
 

8) Cat command to merge the contents of multiple files. 
Command: 
 

$cat "filename1" "filename2" "filename3" > "merged_filename"

Output 
 

Will merge the contents of file in respective order and will insert that content in "merged_filename".
 
 
 

9) Cat command to display the content of all text files in the folder. 
Command: 
 

$cat *.txt

Output 
 

Will show the content of all text files present in the folder.
 

 

10) Cat command can suppress repeated empty lines in output 
Command: 
 

$cat -s geeks.txt

Output 

Will suppress repeated empty lines in output
 
 
Source:https://www.geeksforgeeks.org/cat-command-in-linux-with-examples/ 

 

Saturday, January 14, 2023

Manipulating data in excel,Openpyxl part 6

 
#get cells in the sheet which contains data

print(sheet.calculate_dimension())


#save the workbook

work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\example.xlsx')

#inserting rows
#this will insert three rows after second row,that will change the dimension
sheet.insert_rows(idx=2,amount=3)

print(sheet.calculate_dimension())

#now we will add columns,we are adding columns to c column

sheet.insert_cols(idx=3)

print(sheet.calculate_dimension())

sheet.insert_cols(idx=3,amount=2)

print(sheet.calculate_dimension())

#save the workbook

work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\example.xlsx')

#delete a column

sheet.delete_cols(3)

print(sheet.calculate_dimension())


#save the workbook

#delete multiple columns

sheet.delete_cols(5,2)


work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\example.xlsx')


print(sheet.calculate_dimension())


#change the default sheetname

sheet.title="First Sheet"

print(work_book.active)


work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\example.xlsx')

#Writing multiple rows using list of lists

data=[['Planet','Radius (km)','Distance from Sun (m km)'],
      ['Earth',6371,150],
      ['Mars',3389,228],
      ['Mercury',2440,58]]


#creating a new workbook

planet_wb=openpyxl.Workbook()
planet_sheet=planet_wb['Sheet']

planet_sheet.title='Planets'
for row in data:
    planet_sheet.append(row)

#autofit the columns
    
dims = {}
for row in planet_sheet.rows:
    for cell in row:
        if cell.value:
            #dims[cell.column] = max((dims.get(cell.column, 0), len(str(cell.value))))
            dims[cell.column_letter] = max((dims.get(cell.column_letter, 0), len(str(cell.value))))
for col, value in dims.items():
    planet_sheet.column_dimensions[col].width = value

    
print(planet_sheet.calculate_dimension())
planet_wb.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\planets.xlsx')


Autofit the columns in excel using openpyxl,openpyxl part 5

 #autofit the columns


#planet_sheet = your current worksheet   
dims = {}
for row in planet_sheet.rows:
    for cell in row:
        if cell.value:
            #dims[cell.column] = max((dims.get(cell.column, 0), len(str(cell.value))))
            dims[cell.column_letter] = max((dims.get(cell.column_letter, 0), len(str(cell.value))))
for col, value in dims.items():
    planet_sheet.column_dimensions[col].width = value

 

Source:https://stackoverflow.com/questions/13197574/openpyxl-adjust-column-width-size

Openpyxl part 4,writing to excel file using openpyxl

 #creating new workbook


work_book=openpyxl.Workbook()

#to see the active sheet
print(work_book.active)

#create a handle to the sheet

sheet=work_book['Sheet']

#write value in individual cells

sheet['A1']='Hello'
sheet['B1']='Excel'
sheet['C1']='Users!'

print(sheet['A1'].value)
print(sheet['B1'].value)
print(sheet['C1'].value)

#save the workbook

#work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\example.xlsx')
import os
print("File location using os.getcwd():", os.getcwd())
work_book.save('example.xlsx')

#get cells in the sheet which contains data

print(sheet.calculate_dimension())


#add data after the dimension

sheet.append(['One','row','of','text'])


#get cells in the sheet which contains data

print(sheet.calculate_dimension())


#save the workbook

work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\example.xlsx')