Conversion of a YAML file to XLSX using Python

I want to convert a set of yaml files in a folder into an xlsx file. I thought I’d start with trying to convert one yaml file into an xlsx file. The yaml files in the folder are all in the format given below:

info:
    city: Bangalore
    competition: IPL
    dates:
       - 2008-04-18
    gender: male
    match_type: T20
    outcome:
           by:
              runs: 140
           winner: Kolkata Knight Riders
    overs: 20
    player_of_match:
        - BB McCullum
    teams:
        - Royal Challengers Bangalore
        - Kolkata Knight Riders
    toss:
        decision: field
    winner: Royal Challengers Bangalore
    umpires:
        - Asad Rauf
        - RE Koertzen
    venue: M Chinnaswamy Stadium
    innings:
        - 1st innings:
        team: Kolkata Knight Riders
        deliveries:
                     - 0.1:
                           batsman: SC Ganguly
                           bowler: P Kumar
                           extras:
                                  legbyes: 1
                           non_striker: BB McCullum
                           runs:
                                batsman: 0
                                extras: 1
                           total: 1

The data continues for each ball of the match (0.2, 0.3, 0.4 … 20.0) and shifts to the second half of the game (second innings) and continues further

My attempt at converting one of these yaml file into an xlsx file:

import pandas as pd
import yaml as ya
with open(r"location of folder") as f:
    
    data = ya.load(f, Loader=ya.FullLoader)
    df1=pd.DataFrame(data('info'))
    df1.to_excel(r"location of folderoutput.xlsx")

However, after running the above code, I got the following errors:

File "c:Userskosalhelloprj.py", line 8, in <module>
    df1=pd.DataFrame(data('info'))
  File "C:Userskosalanaconda3libsite-packagespandascoreframe.py", line 529, in __init__
    mgr = init_dict(data, index, columns, dtype=dtype)
  File "C:Userskosalanaconda3libsite-packagespandascoreinternalsconstruction.py", line 287, in init_dict
    return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
  File "C:Userskosalanaconda3libsite-packagespandascoreinternalsconstruction.py", line 80, in arrays_to_mgr
    index = extract_index(arrays)
  File "C:Userskosalanaconda3libsite-packagespandascoreinternalsconstruction.py", line 401, in extract_index
    raise ValueError("arrays must all be same length")

I do realize why this error is coming up but I have no idea as to how I should go about fixing it.

P.S. I can’t find an appropriate tag for this question and hence have used the ‘python’ tag.

Where is launchctl user overrides.plist file located on macOS Catalina?

Where is launchctl user overrides.plist file located on macOS Catalina? – Ask Different

python – How to save screen output into a text file

So I need to create a script and save the info into a text file, and here is what I did:

import platform

def bios_version():

    uname_result = platform.uname()

    pl = {}

    pl('BIOS version') = uname_result.version

    for a, b in pl.items():

        print(a, ":", b)


print(bios_version())

save_path = 'D:/'

name_of_file = input("What is the name of the file: ")

completeName = os.path.join(save_path, name_of_file+".txt")

f = open(completeName, "w")

f.write(bios_version())

f.close

So it return:
f.write(bios_version())
TypeError: write() argument must be str, not None”

rom flashing – Heimdall Error (PIT file)

I a have a PC running Lubuntu 16.04.06. I installed heimdall 1.4.1 in order to flash a custom recovery. It always fails to download the PIT file, part #16 to be specific. I tried multiple devices and it just gives the same error. I also tried JOdin3 before but it wouldn’t run when I execute the binary. Is it possible to fix this error I keep getting in heimdall? or does anyone have a heimdall build that’s working?

disk utility – How to use internal HDD as a file sharing drive if I boot from external SSD on mac mini?

I’m running Mojave 10.14.6 on mac mini late 2014.

It has internal hdd drive. I bought an external ssd to speed things up and run everything from it, and use internal hdd as a data storagetime machine

I installed OS on ssd and am running the mac from it, but I can’t seem to erase the internal hdd drive. When trying to partition it in Disk utility I’m getting an error

The volume “osx” on disk1s1 couldn’t be unmounted because it is in use by process 82 (securityd)

After this error happened, disk utility shows that hdd has two partitions, 500gb each (that’s how I set it up on ‘partitioning’ step), but I can see only the partition that was there before, no new partition that I added. Might sound confusing – please see the screenshots here.

Now, I’m very sure that I run OS from external SSD, so I don’t understand why any process would use internal hdd and what should I do from now on.

So the question is, how do I use internal hdd as a data storage drive, and erase the OS from it?

header – Unable to resolve the source file for ‘frontend/Babycry/theme/en_US/css/images/cart.png’

i want to replace the minicart icon in header with custom image, i added the image in vendor/theme/web/images/cart.png, and i added the css like

.minicart-wrapper a.action.showcart::before {
    background-image: url('images/cart.png');
}

but when i inspect and open the image url (http://magento.com/static/version1618657572/frontend/Babycry/theme/en_US/css/images/cart.png)

this error is coming.

Unable to resolve the source file for
‘frontend/Babycry/theme/en_US/css/images/cart.png’

#1
MagentoFrameworkAppStaticResource->launch() called at
(vendormagentoframeworkAppBootstrap.php:263)
#2 MagentoFrameworkAppBootstrap->run() called at (pubstatic.php:13) 

shell – csh script to look for certain parameters in one file and the replacing corresponding parameters in another file

I am new to shell scripting.

I need to write a csh script to grep out the “warning (code 123)” statements from file1.txt and then extract the last field of each such line i.e. sw1(1), sw1(2), sw1(3) etc.

Now I need to find the lines from file2.txt which contains this extracted fields (i.e. sw1(0), sw1(1), sw1(2) etc) and need to extract the second field from each such lines i.e. qwe, asd, zxc etc.

Now from file3.txt I need to replace sw1(1), sw1(2), sw1(3) etc with qwe, asd, zxc respectively.

Example:
file1.txt

 .
 .
 warning (code 123): Please replace kei.out.sw1(1)
 warning (code 123): Please replace kei.out.sw1(2)
 warning (code 123): Please replace kei.out.sw1(3)  
 warning (code 123): Please replace kei.out.sw1(4)
 warning (code 123): Please replace kei.out.sw1(5)
 .
 .

file2.txt

.
.
.
DSA qwe (W(rty), R(ase), Y(dfg), Q(sw1(1)))
DSA asd (W(fgh), R(ase), Y(kjf), Q(sw1(2)))
DSA zxc (W(jkm), R(ase), Y(dfg), Q(sw1(3)))
DSA iop (W(dfg), R(ase), Y(dfg), Q(sw1(4)))
.
.
.

file3.txt

.
.
abc/mnp/lims/sw(1)
abc/mnp/lims/sw(1)
abc/mnp/lims/sw(1)
abc/mnp/lims/sw(1)
.
.

Therefore, my updated file3.txt should look like,

.
.
abc/mnp/lims/qwe
abc/mnp/lims/asd
abc/mnp/lims/zxc
abc/mnp/lims/iop
.
.

Can a publicly shared file stored in my Google Drive be deleted by someone having “Anyone with the link” editor rights?

Short answer. No.
None of the editors having “Anyone with the link” editor rights can delete the file.
The only person who can delete this file is the owner of the file.

You can see that when changing the sharing permissions of a file to Anyone with the link can Edit, the option of changing the settings is greyed out with the message Settings are disabled for public links

enter image description here


Furthermore, when within the file Edit menu , the option of moving the file is greyed out as well.

enter image description here

One can only use the Add a shortcut to Drive.
Even if one later decides to delete this created shortcut from the drive, the original file remains intact.

Conclusion
You can safely, publicly share, any file stored in your Google Drive using “Anyone with the link” editor rights.
Your publicly shared file will never be deleted by anyone else but you.


Important Note
Please do NOT confuse the above with editors added under Share with people and groups.
They CAN delete the file and even deprive you of your rights as the owner.

design – File parsing in UI Layer or Application Services Layer

Let’s say that I have a list of financial transactions that I need to read in from the file. I want to make the best guess I can at what account should be credited/debited based on the transaction memo compared to past transactions.

For example, if Wal-Mart was used with ‘Shopping’ then if a transaction that gets read in from the file with Wal-Mart as the description should show ‘Shopping’. If there cannot be a match found, then the application should make the best guess and get feedback from the user. If there is not a best match then the user should be asked which account makes most sense.

To me, there is a lot of interaction with the user so it would make sense that this should all live in the UI layer. Once all the transactions are paired with accounts, then it should be sent to the Application Service layer to be saved.

Right now I’m just using a CLI, so I could inject an object that inherits from a ‘Presenter’ interface that the Application Service uses; however, this will not work when I get rid of the CLI and want to use a REST API around the Application Service layer.

Does it make sense to just include all this logic in the UI layer?

How to set the default command, with options, to open a file on MacOS?

How to set the default command, with options, to open a file on MacOS? – Ask Different

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123