-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojectfile2.py
119 lines (54 loc) · 2.08 KB
/
projectfile2.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- coding: utf-8 -*-
"""
Created on Wed May 15 19:04:51 2024
@author: shash
"""
#for tilt
import pandas as pd
import glob
import os
path=os.chdir(r"D:\Submission of BTP Final Python code and its Datasets\Bi-Crystal\Bi-Crystal\CSL GBs Al_Al\tilt")
my_files = glob.glob("*")
dataframes = []
# Iterate over the text files and create a dataframe for each one
for text_file in my_files:
# Read the text file into a dataframe
df = pd.read_table(text_file,delimiter=" ")
df['file_name']=text_file.split("/")[-1]
df['tilt/twist']='tilt'
# Append the dataframe to the list of dataframes
dataframes.append(df)
# Concatenate the dataframes into a single dataframe
df = pd.concat(dataframes)
# Print the dataframe
print(df)
#for twist
import pandas as pd
import glob
import os
path2=os.chdir(r"D:\Submission of BTP Final Python code and its Datasets\Bi-Crystal\Bi-Crystal\CSL GBs Al_Al\twist")
my_files2 = glob.glob("*")
dataframes2 = []
# Iterate over the text files and create a dataframe for each one
for text_file2 in my_files2:
# Read the text file into a dataframe
df2 = pd.read_table(text_file2,delimiter=" ")
df2['file_name']=text_file2.split("/")[-1]
df2['tilt/twist']='twist'
# Append the dataframe to the list of dataframes
dataframes2.append(df2)
# Concatenate the dataframes into a single dataframe
df2 = pd.concat(dataframes2)
# Print the dataframe
print(df2)
# Combined_table list for tilt and twist
combined_table=pd.concat([df,df2])
# Print combined_table dataframe
print(combined_table)
import pickle
folder_path = 'D:\Submission of BTP Final Python code and its Datasets\Combined_table_list'
if not os.path.exists(folder_path):
os.makedirs(folder_path)
file_path = os.path.join(folder_path, 'combined_table_list.pkl')
with open(file_path, 'wb') as file:
pickle.dump(combined_table, file)