விக்கிமூலம்:பைத்தான்3நிரல்கள்/அட்டவணை நிரப்பி தொகுதி

import re, csv


# this is to write volumn names in the ws index format
# volumn_name = vn
vn = 'அட்டவணை:தரும தீபிகை 1.pdf'
needed_vn_num = 7

with open ('needed_vn_names.csv', 'a') as need_file:
	file_writer = need_file.write('<big>')	
	
	
vn_prefix = vn.split(':')[0]
if 'அட்டவணை' in vn_prefix or 'index' in vn_prefix:
	print("'" + vn_prefix + "'" + 'is available.')
else:
	print('Check; index name not available')

	
vn_suffix = vn.split('.')[-1]
pattern1 = '[a-z]+'
if re.search(pattern1, vn_suffix): # file_extension  
	print("'" + vn_suffix + "'" + 'is available.')
else:
	print('Check; file extension not available')

		
vn_middle = vn.replace(vn_prefix,'').replace(':','' ).replace(vn_suffix,'').replace('.','' )	
print(vn_middle)


pattern2 = '[0-9]+$'
if re.search(pattern2, vn_middle): # file_extension  
	print('volumn number is available in' + "'" + vn_middle + "'. So, " )
	no_num_vn_middle = re.sub(pattern2,'', vn_middle)
	print(no_num_vn_middle + ' = the volumn number is removed')
	

	x = range(needed_vn_num)	
	for num in x:
		num_str = num+1
		needed_vn_num = '[[' + vn_prefix + ':' + no_num_vn_middle + str(num_str) + '.' + vn_suffix + '|' + str(num_str) + ']] - '

		with open ('needed_vn_names.csv', 'a') as need_file:
			file_writer = need_file.write(needed_vn_num)
			
		print(needed_vn_num, end = '') 
		
else:
	print('volumn number is not available in' + "'" + vn_middle + "'")
	
	
				
with open ('needed_vn_names.csv', 'a') as need_file:
	file_writer = need_file.write('</big>')	

	
f = open("needed_vn_names.csv", "r")
fileCleanUp = f.read().replace('- </big>',' </big>') 
print(fileCleanUp) 

with open ('needed_vn_names.csv', 'w') as need_file:
	file_writer = need_file.write(fileCleanUp)
  • செய்ய வேண்டியன
  • உரிய அட்டவணைகளைத் திறந்து தானாகவே நிரப்பும் நுட்பத்தினை இணைக்க வேண்டும்.