Skip to content

Commit fbe9cd3

Browse files
committed
initial commit
1 parent 1818394 commit fbe9cd3

File tree

1,619 files changed

+8962117
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,619 files changed

+8962117
-2
lines changed

.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# OS
2+
.DS_Store
3+
4+
# Python
5+
*.pyc
6+
*.pyo
7+
8+
# Common IDEs
9+
*.swp
10+
.idea/
11+
.buildpath
12+
.project
13+
.settings
14+
atlassian-ide-plugin.xml
15+
*.sublime-*
16+
17+
# Project
18+
/mothra/local_settings.py
19+
/mothra/public/static
20+
/mothra/public/media
21+
/mothra/public/files
22+
/mothra/backup
23+
mothra-env/
24+
build/
25+
26+
# SQLite
27+
/mothra/mothra.db
28+
/mothra/mothra.db-journal

README.md

+64-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
clowdflows
2-
==========
1+
# ClowdFlows Project (codename mothra) #
2+
## Prerequisites ##
3+
4+
- python >= 2.5
5+
- pip
6+
- virtualenv/wrapper (optional)
7+
8+
## Installation ##
9+
### Creating the environment ###
10+
Create a virtual python environment for the project.
11+
If you're not using virtualenv or virtualenvwrapper you may skip this step.
12+
13+
#### For virtualenvwrapper ####
14+
```bash
15+
mkvirtualenv --no-site-packages mothra-env
16+
```
17+
18+
#### For virtualenv ####
19+
```bash
20+
virtualenv --no-site-packages mothra-env
21+
cd mothra-env
22+
source bin/activate
23+
```
24+
25+
### Clone the code ###
26+
Obtain the url to your git repository.
27+
28+
```bash
29+
git clone [email protected]:janezkranjc/clowdflows.git
30+
```
31+
32+
### Install requirements ###
33+
```bash
34+
cd clowdflows
35+
pip install -r requirements.txt
36+
```
37+
38+
### Configure project ###
39+
```bash
40+
cp mothra/__local_settings.py mothra/local_settings.py
41+
vi mothra/local_settings.py
42+
```
43+
44+
### Sync database ###
45+
```bash
46+
python manage.py syncdb
47+
```
48+
49+
### Migrate database ###
50+
```bash
51+
python manage.py migrate
52+
```
53+
54+
## Running ##
55+
```bash
56+
python manage.py runserver
57+
```
58+
59+
## Running with debugger ##
60+
```bash
61+
python manage.py runserver_plus
62+
```
63+
64+
Open browser to http://127.0.0.1:8000

apache/virtualhosts.conf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ServerName workflows.ijs.si
2+
3+
WSGIDaemonProcess workflow.ijs.si processes=4 threads=20 python-path=/srv/django-projects/mothra:/srv/django-envs/mothra/lib/python2.7/site-packages
4+
WSGIProcessGroup workflow.ijs.si
5+
6+
WSGIScriptAlias / /srv/django-projects/mothra/apache/wsgi_app.py
7+
<Directory /srv/django-projects/mothra/apache>
8+
Order allow,deny
9+
Allow from all
10+
</Directory>
11+
12+
Alias /static /srv/django-projects/mothra/mothra/public/static
13+
<Directory /srv/django-projects/mothra/mothra/public/static>
14+
Order allow,deny
15+
Allow from all
16+
</Directory>
17+
18+
Alias /media /srv/django-projects/mothra/mothra/public/media
19+
<Directory /srv/django-projects/mothra/mothra/public/media>
20+
Order allow,deny
21+
Allow from all
22+
</Directory>
23+
WSGIApplicationGroup %{GLOBAL}

apache/wsgi_app.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
WSGI config for mothra project.
3+
4+
This module contains the WSGI application used by Django's development server
5+
and any production WSGI deployments. It should expose a module-level variable
6+
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
7+
this application via the ``WSGI_APPLICATION`` setting.
8+
9+
Usually you will have the standard Django WSGI application here, but it also
10+
might make sense to replace the whole Django WSGI application with a custom one
11+
that later delegates to the Django one. For example, you could introduce WSGI
12+
middleware here, or combine a Django application with an application of another
13+
framework.
14+
15+
"""
16+
import os
17+
import sys
18+
import site
19+
20+
site.addsitedir('/srv/django-envs/mothra/lib/python2.7/site-packages')
21+
22+
project_path = '/srv/django-projects/mothra'
23+
if project_path not in sys.path:
24+
sys.path.append(project_path)
25+
26+
os.environ["DJANGO_SETTINGS_MODULE"] = "mothra.settings"
27+
28+
# This application object is used by any WSGI server configured to use this
29+
# file. This includes Django's development server, if the WSGI_APPLICATION
30+
# setting points here.
31+
from django.core.wsgi import get_wsgi_application
32+
application = get_wsgi_application()
33+
34+
# Apply WSGI middleware here.
35+
# from helloworld.wsgi import HelloWorldApplication
36+
# application = HelloWorldApplication(application)

csv2arff-read-only/.svn/all-wcprops

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
K 25
2+
svn:wc:ra_dav:version-url
3+
V 21
4+
/svn/!svn/ver/3/trunk
5+
END
6+
csv2arff.py
7+
K 25
8+
svn:wc:ra_dav:version-url
9+
V 33
10+
/svn/!svn/ver/2/trunk/csv2arff.py
11+
END

csv2arff-read-only/.svn/entries

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
10
2+
3+
dir
4+
3
5+
http://csv2arff.googlecode.com/svn/trunk
6+
http://csv2arff.googlecode.com/svn
7+
8+
9+
10+
2008-07-17T09:36:53.100851Z
11+
3
12+
bianchimro
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
6882ac45-3452-0410-b3ff-f72446878f82
28+
29+
csv2arff.py
30+
file
31+
32+
33+
34+
35+
2013-06-20T08:20:15.000000Z
36+
3cd48889501c569b6bd45ba00a39be7d
37+
2008-07-17T09:32:31.216611Z
38+
2
39+
bianchimro
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
3968
62+
63+
test_csv2arff
64+
dir
65+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# -*- coding: cp1252 -*-
2+
import csv
3+
import sys
4+
from xml.dom import minidom
5+
6+
7+
8+
9+
10+
11+
def get_attributes(file_xml):
12+
out = []
13+
dom1 = minidom.parse(file_xml)
14+
for node in dom1.getElementsByTagName('attribute'):
15+
out.append({
16+
'name': node.getAttribute('name') ,
17+
'atype': node.getAttribute('atype'),
18+
'format':node.getAttribute('format'),
19+
'skip':node.getAttribute('skip')
20+
21+
})
22+
#print out
23+
return out
24+
25+
def get_relation(file_xml):
26+
dom1 = minidom.parse(file_xml)
27+
out=''
28+
delimiter=''
29+
for node in dom1.getElementsByTagName('csv'):
30+
out=node.getAttribute('name')
31+
delimiter=node.getAttribute('delimiter');
32+
if(len(delimiter)==0):
33+
delimiter=';';
34+
print delimiter
35+
return out, delimiter
36+
37+
38+
class csv_arff_converter:
39+
40+
def __init__(self,csv_file, attribute_file, file_out):
41+
self.csv_file = csv_file
42+
self.attribute_file = attribute_file
43+
self.file_out = file_out
44+
45+
def run(self):
46+
47+
classes = []
48+
49+
#read attribute
50+
self.relation_name, self.delimiter = get_relation(attribute_file)
51+
attributes_list = get_attributes(attribute_file)
52+
arff_data = '@RELATION ' + self.relation_name + '\n\n'
53+
54+
55+
for i in attributes_list:
56+
if (i['skip'] != 'yes'):
57+
arff_data += '@ATTRIBUTE '+i['name']+' ' + i['atype']
58+
if (i['atype']=='date'):
59+
arff_data += ' '+i['format']
60+
if (i['atype']=='class'):
61+
arff_data += ' (#@#'+i['name'] + '#@#)'
62+
63+
arff_data +='\n'
64+
classes.append('')
65+
66+
67+
68+
arff_data += '\n@DATA\n'
69+
print classes
70+
#open csv
71+
reader = csv.reader(open(self.csv_file), delimiter=self.delimiter, quoting=csv.QUOTE_NONE)
72+
73+
rnum = 0
74+
75+
76+
for row in reader:
77+
#print row
78+
buff = ''
79+
pos = 0
80+
#print len(row)
81+
#occhio alla lunghezza riga
82+
for j in range(0, len(row)-1):
83+
field = row[j]
84+
85+
if(attributes_list[pos]['skip'] != 'yes'):
86+
87+
if (pos > 0):
88+
buff += ','
89+
if(attributes_list[pos]['atype'] == 'string'):
90+
field = "'" + field + "'"
91+
buff += field
92+
#se � una classe raccolgo i valori
93+
if(attributes_list[pos]['atype'] == 'class'):
94+
if (rnum > 0):
95+
classes[pos]+= ','+ field
96+
else:
97+
classes[pos]+= field
98+
99+
pos += 1
100+
buff += '\n'
101+
arff_data += buff
102+
103+
rnum += 1
104+
105+
106+
pos = 0
107+
for a in classes:
108+
j = a.split(',')
109+
110+
un = list(set(j))
111+
#print un
112+
if (len(un) > 0):
113+
this_replacement = ",".join(un)
114+
#print this_replacement
115+
old_text = '#@#'+ attributes_list[pos]['name'] + '#@#'
116+
#print old_text
117+
arff_data = arff_data.replace(old_text, this_replacement)
118+
pos += 1
119+
120+
#print arff_data
121+
a = open(self.file_out, 'w')
122+
a.write(arff_data)
123+
a.close()
124+
125+
126+
127+
128+
129+
130+
if __name__ == "__main__":
131+
#csv_file = sys.argv[1]
132+
#attribute_file = sys.argv[2]
133+
csv_file = './test_csv2arff/test_dataset_1.csv'
134+
attribute_file = './test_csv2arff/test_dataset_1.att'
135+
136+
instance = csv_arff_converter(csv_file, attribute_file, './test_csv2arff/output.arff')
137+
instance.run()

0 commit comments

Comments
 (0)