2024年9月26日 星期四

xlsx convert csv

xlsx2csv
$ sudo apt install xlsx2csv

Explanation: Array of Search Terms: an array called search_terms where you can add as many keywords as needed.
Loop Through Search Terms: For each converted CSV file, it loops through each search term and checks if it exists in that file using grep.
Output: The script will print messages indicating whether each keyword was found in each CSV file.
#!/bin/bash

# Directory containing the .xlsx files
input_directory="/path/to/xlsx/files"
# Output directory for CSV files
output_directory="/path/to/output/csv/files"
# File containing search terms (one per line)
search_terms_file="/path/to/search_terms.txt"

# Create output directory if it doesn't exist
mkdir -p "$output_directory"

# Read search terms from the specified file into an array
mapfile -t search_terms < "$search_terms_file"

# Loop through all .xlsx files in the input directory
for file in "$input_directory"/*.xlsx; do
    # Check if the file exists
    if [[ -f "$file" ]]; then
        # Generate the output CSV filename
        csv_filename="$output_directory/$(basename "${file%.xlsx}.csv")"
        
        # Convert .xlsx to .csv using xlsx2csv
        xlsx2csv "$file" "$csv_filename"
        
        # Check if the conversion was successful
        if [[ $? -eq 0 ]]; then
            echo "Converted: $file to $csv_filename"
            
            # Search for each term in the converted CSV file
            for search_term in "${search_terms[@]}"; do
                if grep -q "$search_term" "$csv_filename"; then
                    echo "Found '$search_term' in $csv_filename"
                else
                    echo "'$search_term' not found in $csv_filename"
                fi
            done
            
        else
            echo "Failed to convert: $file"
        fi
    fi
done

Create a text file named search_terms.txt and add your keywords, one per line. For example:
apple
banana
cherry



ref: Perplexity

2024年9月23日 星期一

Cuda & cuDNN version

Cuda
$ nvcc --version or nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Jun_13_19:16:58_PDT_2023
Cuda compilation tools, release 12.2, V12.2.91
Build cuda_12.2.r12.2/compiler.32965470_0

Cudnn
$ whereis cudnn.h
cudnn.h: /usr/include/cudnn.h


$ cat /usr/include/cudnn.h
...
...
#include "cudnn_version.h"
#include "cudnn_graph.h"
#include "cudnn_ops.h"
#include "cudnn_adv.h"
#include "cudnn_cnn.h"
...
...


$ whereis cudnn_version.h
cudnn_version.h: /usr/include/cudnn_version.h

$ cat /usr/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 9
#define CUDNN_MINOR 2
#define CUDNN_PATCHLEVEL 1
--
#define CUDNN_VERSION (CUDNN_MAJOR * 10000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

/* cannot use constexpr here since this is a C-only file */

nvidia-smi
$ nvidia-smi
Tue Sep 24 13:17:46 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.01             Driver Version: 535.183.01   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3070 ...    Off | 00000000:01:00.0 Off |                  N/A |
| N/A   34C    P0              N/A /  80W |      8MiB /  8192MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      2010      G   /usr/lib/xorg/Xorg                            4MiB |
+---------------------------------------------------------------------------------------+

2024年8月20日 星期二

Download a specific directory with git command

target directory: https://github.com/yoctoproject/poky/tree/master/meta/recipes-extended/sudo

$ git clone --depth 1 https://github.com/yoctoproject/poky.git
$ cd poky
$ git sparse-checkout init --cone
$ git sparse-checkout set meta/recipes-extended/sudo


should see the meta/recipes-extended/sudo directory
$ tree
.
├── LICENSE
├── LICENSE.GPL-2.0-only
├── LICENSE.MIT
├── MAINTAINERS.md
├── MEMORIAM
├── meta
│   ├── COPYING.MIT
│   ├── recipes-extended
│   │   └── sudo
│   │       ├── files
│   │       │   ├── 0001-sudo.conf.in-fix-conflict-with-multilib.patch
│   │       │   └── sudo.pam
│   │       ├── sudo_1.9.15p5.bb
│   │       └── sudo.inc
│   └── recipes.txt
├── oe-init-build-env
├── README.hardware.md -> meta-yocto-bsp/README.hardware.md
├── README.md -> README.poky.md
├── README.OE-Core.md
├── README.poky.md -> meta-poky/README.poky.md
├── README.qemu.md
└── SECURITY.md

4 directories, 18 files