Getting Started
After you installed this package, the next step is to import the package into your code and start using the functions.
from botcity.plugins.csv import BotCSVPlugin
As a demonstration of the library, let's build a simple example together that will do something cool .
Step 1 of Example
To make the example we will...
# Instantiate the plugin
bot_csv = BotCSVPlugin()
...
Step 2 of Example
# Read from a CSV File, add a row, then sort it
bot_csv.read('read.csv')
bot_csv.add_row([0, 22])
bot_csv.sort(['H1', 'H2'], False)
# Print the result and save it to a CSV file
print(bot_csv.as_dict)
bot_csv.write('write.csv')
...
Complete code
Let's take a look into the complete code:
from botcity.plugins.csv import BotCSVPlugin
# Reads from a CSV File, adds a row, then sorts it
bot_csv = BotCSVPlugin()
bot_csv.read('read.csv')
bot_csv.add_row([0, 22])
bot_csv.sort(['H1', 'H2'], False)
# Prints the result and saves it to a CSV file
print(bot_csv.as_dict)
bot_csv.write('write.csv')
Pro Tip
This plugin allow you to use method chaining
so the code above could be written as:
BotCSVPlugin().read('read.csv').add_row([0, 22]).sort(['H1', 'H2'], False).write('write.csv')
Next Steps
Check our examples and experiment with the API. Let us know where it can be improved.
Have fun automating!