File size: 659 Bytes
1367fa8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Created By: ishwor subedi
Date: 2024-10-04
"""
import pandas as pd


def csv_read_batch_code(dataframe):
    dataframe.dropna()

    dataframe['Logic ID'].unique()

    unique_value_indices = {}

    for logic_id in dataframe['Logic ID'].unique():
        row_indices = dataframe[dataframe['Logic ID'] == logic_id].index.tolist()
        unique_value_indices[logic_id] = [min(row_indices), max(row_indices)]

    print(unique_value_indices)

    code_dict = {}

    for logic_id, (min_row, max_row) in unique_value_indices.items():
        codes = dataframe.loc[min_row:max_row, 'Code'].tolist()

        code_dict[logic_id] = codes

    return code_dict