My video_man.txt
file contains a table I created using PrettyTable to organize the output. Is there a way to get a similar output as shown without using PrettyTable module?
Type Name Video Version
Sole/Viewer 0.2.5
Sole/Pedal 0.1.5
Cram/Node 0.2.8
Here is code I created using PrettyTable:
def create_table(TypeList):
p = PrettyTable()
p.field_names = ["Type Name", "Video Version"]
for (typeName, testPath) in TypeList:
video_version_string = extract_video_version(testPath)
p.add_row([typeName, video_version_string])
# Generate text file
print(root_directory)
file = open(root_directory + "/video_release.txt", "w")
file.write(str(p))
file.close()
This code yields the following output
+---------------------------------------+------------------+
| Type Name | Video Version |
+---------------------------------------+------------------+
| Sole/Viewer | 0.2.5 |
| Sole/Pedal | 0.1.5 |
| Cram/Node | 0.2.8 |
| | |
+---------------------------------------+------------------+
I was simply experimenting with PrettyTable but don't want to use it since I can't use modules in my scenario. I tried to manipulate the code a bit to try and get the output shown in the first result in the beginning, but I am struggling to get the correct output. Here is the code:
def create_table(TypeList):
field_names = ["Type Name", "Video Version"]
for (typeName, testPath) in TypeList:
video_version_string = extract_video_version(testPath)
test_list = [
[typeName, video_version_string]
]
print("{:<8} {:<15} {:<10}".format('Type Name','Video Version'))
for data in test_list:
typeName, video_version_string = data
print("{:<8} {:<15} {:<10}".format(typeName, video_version_string))
# Generate text file
print(root_directory)
file = open(root_directory + "/video_release.txt", "w")
file.write(test_list)
file.close()
Your help is appreciated. Thank you.