User Tools

Site Tools


csv_a_grafico_y_x_con_matplotlib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
csv_a_grafico_y_x_con_matplotlib [2024/05/02 17:41] – created osocsv_a_grafico_y_x_con_matplotlib [2024/10/17 21:42] (current) – external edit 127.0.0.1
Line 3: Line 3:
 **Objective:** The purpose of this script is to fetch the latest average value of the "dólar blue" (unofficial dollar exchange rate in Argentina) from an API and visualize its historical trend in a transparent PNG image. **Objective:** The purpose of this script is to fetch the latest average value of the "dólar blue" (unofficial dollar exchange rate in Argentina) from an API and visualize its historical trend in a transparent PNG image.
  
 +Lo de Pagano es por Marcela:
 +
 +{{ :574818.jpg?nolink&400 |}}
  
 ===== Code ===== ===== Code =====
Line 102: Line 105:
 **Note:** This script requires the following dependencies: requests, json, csv, matplotlib, pandas, Pillow. **Note:** This script requires the following dependencies: requests, json, csv, matplotlib, pandas, Pillow.
 </WRAP> </WRAP>
 +
 +==== Results ====
 +
 +https://repo.facundoitest.space/usdPagano/latest.jpg
 +
 +{{:latest.jpg?nolink&500|}}
  
 The script provides a convenient way to visualize the recent trend of the blue dollar exchange rate, aiding in financial analysis and decision-making. The script provides a convenient way to visualize the recent trend of the blue dollar exchange rate, aiding in financial analysis and decision-making.
  
 +==== Sending the results... ====
 +
 +<code python>
 +def dolarpagano(update: Update, context: CallbackContext) -> None:
 +    now = datetime.now()
 +    version = now.strftime('%d%m%Y_%H%M' # Get the current date and time in the specified format
 +    url = f"https://repo.facundoitest.space/usdPagano/latest.jpg?v={version}"
 +    update.message.reply_text(url)
 +</code>
 +
 +This snippet defines a function called `dolarpagano` that accepts two arguments: `update` and `context`, which are provided by the `python-telegram-bot` library to handle updates and message context in Telegram.
 +
 +Within the function:
 +  - It gets the current date and time using `datetime.now()`.
 +  - The date and time are formatted as a string in the 'ddmmYYYY_HHMM' format using the `strftime()` method, where 'dd' represents the day, 'mm' the month, 'YYYY' the year, 'HH' the hour, and 'MM' the minutes.
 +  - A URL is constructed using this formatted string to include the updated version of the image resource. This is achieved by concatenating the base URL string with a query parameter `v` carrying the updated timestamp.
 +  - Finally, it responds to the Telegram message with the generated URL using the `reply_text()` method of the `update.message` object.
 +
 +In summary, this function generates a URL pointing to the latest image of a dollar meme and sends it as a reply to a message in Telegram with the 'v' parameter to bypass Telegram's thumbnail cache.
csv_a_grafico_y_x_con_matplotlib.1714671713.txt.gz · Last modified: 2024/10/17 21:42 (external edit)