PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 28, 2022

[FIXED] How to adjust the measurement of cells in .csv/.xlsx file?

 August 28, 2022     csv, excel, file, pandas, python     No comments   

Issue

How can I adjust the measurement of the cells in the .csv/.xlsx file?

# Modules
import datetime, os, sys
import urllib.request as request
import pandas as pd

    #Sort Values From URL
Application_value = "org.thoughtcrime.securesms"
Version_value = "3.2.15"
print(Application_value)
        
#Insert into file.txt
with  open("log.csv", "a") as file:
    #content = str("Application_value") + ',' + str("Version_value") + '\n'
    content = str(Application_value) + ',' + str(Version_value) + '\n'
    print("Appended!")
    file.write(content)
    file.close()
df = pd.read_csv('log.csv')
df.to_excel('recordings.xlsx', 'Sheet1')

Let's say I wanted the cell of the first entry to be 25px or a similar measurement.


Solution

You can access to workbook and active sheet through ExcelWriter:

with pd.ExcelWriter('output.xlsx', engine='openpyxl') as writer:
    df.to_excel(writer, sheet_name='Sheet1', index=False)
    writer.book.active.column_dimensions['A'].width = 25


Answered By - Corralien
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing