在橙色中,有用于导入CSV
文件的“数据”小部件,还有“选择列”小部件以选择功能,目标和元。
如何使用Python Script
小部件来做到这一点?
例如:
CSV file = D:\passenger\data.csv
feature = age | gender | job
meta = name
target = seat_class
答案 0 :(得分:2)
在“ Python脚本”小部件中,以下应该起作用:
from Orange import Table
# load your path
data = Table('D:\passenger\data.csv')
答案 1 :(得分:0)
如果CSV文件与python脚本位于同一文件夹中
@Data
@Entity
@EqualsAndHashCode( callSuper = false )
@EntityListeners( AuditingEntityListener.class )
@Table( name = "subscription" )
public class Subscription
{
@Id
@GeneratedValue( strategy = GenerationType.AUTO )
@Setter( AccessLevel.PROTECTED )
@Column( name = "sub_id" )
private UUID id;
@ManyToMany( fetch = FetchType.LAZY )
@JoinTable( name = "membersubscription", joinColumns = { @JoinColumn( name = "sub_id" ) }, inverseJoinColumns = { @JoinColumn( name = "m_id" ) } )
private List<MemberSubscription> memberIds1;// i want to map with member table which is created by different project but in same database.
//other columns
}
data.csv的内容:
#!/usr/bin/env python
import csv
from collections import defaultdict
columns = defaultdict(list) # each value in each column is appended to a list
with open('data.csv') as f:
reader = csv.reader(f)
next(reader, None) # skip header in 1st row
for row in reader:
for (i,v) in enumerate(row):
columns[i].append(v)
print('Column 1 Values: ', columns[0])
print('Column 2 Values: ', columns[1])
print('Column 3 Values: ', columns[2])
输出:
age,gender,job
25,M,IT
35,F,Operations