##// END OF EJS Templates
- Finalizada la funcion que lee(importa) un archivo ABS sin guardarlo a la base de datos....
jsalyrosas -
r152:153
parent child
Show More
@@ -53,9 +53,10
53 No newline at end of file
53
54 pattern = models.ForeignKey(Pattern) No newline at end of file
54 pattern = models.ForeignKey(Pattern)
55 value = models.TextField()
55 value = models.TextField()
No newline at end of file
56 tx = models.TextField(null=True)
56 tx = models.TextField()
No newline at end of file
No newline at end of file
57 rx = models.TextField(null=True)
57 rx = models.TextField()
No newline at end of file
No newline at end of file
58 ues = models.CharField(max_length=120, null=True)
58 ues = models.CharField(max_length=120) No newline at end of file
No newline at end of file
59 only_rx = models.PositiveSmallIntegerField(default=0) No newline at end of file
59 date_create = models.DateTimeField() No newline at end of file
60 date_create = models.DateTimeField()
60 date_modified = models.DateTimeField(null=True) No newline at end of file
61 date_modified = models.DateTimeField(null=True)
61 hits = models.PositiveIntegerField() No newline at end of file
62 hits = models.PositiveIntegerField()
@@ -252,23 +252,6
252 filename = '/tmp/'+txtFilename.name No newline at end of file
252 filename = '/tmp/'+txtFilename.name
253 readFile = readABSFile(filename) No newline at end of file
253 readFile = readABSFile(filename)
254 expName, num_patterns, patterns = readFile.getMetadata()
254 expName, num_patterns, patterns = readFile.getMetadata()
No newline at end of file
255
No newline at end of file
256 '''
No newline at end of file
257 f = open('/tmp/'+txtFilename.name, 'r')
No newline at end of file
258 newContent = f.readlines()
No newline at end of file
259 f.close()
No newline at end of file
260 content = ""
No newline at end of file
261 for i,line in enumerate(newContent):
No newline at end of file
262 if i == 0:
No newline at end of file
263 newLine = line.replace("'","")
No newline at end of file
264 pos = newLine.find("=")
No newline at end of file
265 expName = newLine[pos+1:].strip()
No newline at end of file
266 elif i == 2:
No newline at end of file
267 pos = line.find("=")
No newline at end of file
268 num_patterns = line[pos+1:].strip()
No newline at end of file
269 else:
No newline at end of file
270 content += line
No newline at end of file
271 ''' No newline at end of file
272 else: No newline at end of file
255 else:
273 txtFilename = "Error" No newline at end of file
256 txtFilename = "Error"
274 #content = "Error" No newline at end of file
257 #content = "Error"
@@ -6,7 +6,7
6 * font-family: 'Roboto Condensed', sans-serif; No newline at end of file
6 * font-family: 'Roboto Condensed', sans-serif;
7 */ No newline at end of file
7 */
8
8
No newline at end of file
9 body { font-size: 12px; } No newline at end of file
9 body { font-size: 11px; } No newline at end of file
10 header {border: 1px solid #fcc; font-size: 2em; height: 50px; text-align: center; line-height: 50px} No newline at end of file
10 header {border: 1px solid #fcc; font-size: 2em; height: 50px; text-align: center; line-height: 50px}
11 #schema {margin: 0 auto; width: 980px; border: 1px solid #f00; padding: 10px 10px 10px 10px} No newline at end of file
11 #schema {margin: 0 auto; width: 980px; border: 1px solid #f00; padding: 10px 10px 10px 10px}
12 #content {border: 1px solid #1cc; margin-top: 5px; margin-bottom: 5px} No newline at end of file
12 #content {border: 1px solid #1cc; margin-top: 5px; margin-bottom: 5px}
@@ -5,29 +5,30
5 <div id="content"> No newline at end of file
5 <div id="content">
6 <div id="divPattern"> No newline at end of file
6 <div id="divPattern">
7 <div class="divUes">
7 <div class="divUes">
No newline at end of file
8 <label for="lblFile">File: {{ txtFilename }}</label> No newline at end of file
8 <label for="lblFile">File:</label>
No newline at end of file
9 <label for="lblFilename">{{ txtFilename }}</label> No newline at end of file
10 </div> No newline at end of file
9 </div>
11 <div class="divUes">
10 <div class="divUes">
No newline at end of file
11 <label for="lblExperiment">Experiment: {{ expName }}</label><br />
12 <label for="lblExperiment">Experiment:</label>
No newline at end of file
No newline at end of file
12 <label for="lblNumber">Number of patterns: {{ num_patterns }}</label> No newline at end of file
13 <p>{{ expName }}</p>
No newline at end of file
14 <label for="lblNumber">Number of patterns:</label>
No newline at end of file
15 <p>{{ num_patterns }}</p> No newline at end of file
16 </div> No newline at end of file
13 </div>
17 {% if patterns %}
14 {% if patterns %}
No newline at end of file
15 <div class="divListofPatterns"> No newline at end of file
18 <div> No newline at end of file
19 {% for element in patterns %} No newline at end of file
16 {% for element in patterns %}
17 <div class="divPattern"> No newline at end of file
20 <div> No newline at end of file
18 <div>
21 <label for="lblNumber">Pattern: {{ element.number }}</label> No newline at end of file
19 <label for="lblNumber">Pattern: {{ element.number }}</label>
22 </div>
20 </div>
No newline at end of file
21 <div class="divAntenna"> No newline at end of file
23 <div> No newline at end of file
24 <label for="lblAntennaUp">Antenna Up:</label> No newline at end of file
22 <label for="lblAntennaUp">Antenna Up:</label>
25 <p>{{ element.up }}</p> No newline at end of file
23 <p>{{ element.up }}</p>
26 </div>
24 </div>
No newline at end of file
25 <div class="divAntenna"> No newline at end of file
27 <div> No newline at end of file
28 <label for="lblAntennaDown">Antenna Down:</label> No newline at end of file
26 <label for="lblAntennaDown">Antenna Down:</label>
29 <p>{{ element.down }}</p> No newline at end of file
27 <p>{{ element.down }}</p>
30 </div> No newline at end of file
28 </div>
29 <div class="cleardivs"></div>
No newline at end of file
30 </div>
No newline at end of file
31 <div class="cleardivs"></div> No newline at end of file
31 {% endfor %} No newline at end of file
32 {% endfor %}
32 </div> No newline at end of file
33 </div>
33 {% endif %} No newline at end of file
34 {% endif %}
@@ -37,14 +37,34
37 No newline at end of file
37
38 def getPatterns(self, content): No newline at end of file
38 def getPatterns(self, content):
39 lsPattern = []
39 lsPattern = []
No newline at end of file
40 patterns = self.getValueofPattern(content)
40 index = 8
No newline at end of file
No newline at end of file
41 for element in patterns:
41
No newline at end of file
No newline at end of file
42 if element != "":
42 for i in range(0, self.number_patterns):
No newline at end of file
No newline at end of file
43 strValue = element.replace("=","/")
43 first = i+index
No newline at end of file
No newline at end of file
44 pattern = strValue.split("/")
44 second = first+index
No newline at end of file
No newline at end of file
45 dicPattern = {"number" : pattern[0], "up" : pattern[1], "down" : pattern[2]} No newline at end of file
45 antennaUp = content[i:first]
No newline at end of file
46 antennaDown = content[first+1:second]
No newline at end of file
47 dicPattern = {"number" : content[i], "up" : antennaUp, "down" : antennaDown} No newline at end of file
48 lsPattern.append(dicPattern) No newline at end of file
46 lsPattern.append(dicPattern)
49 No newline at end of file
47
50 return lsPattern No newline at end of file
48 return lsPattern
49
No newline at end of file
50 def getValueofPattern(self, content):
No newline at end of file
51 strValue = "".join(element.replace("\n","+").strip() for element in content)
No newline at end of file
52 strValue = strValue.replace("\r","+")
No newline at end of file
53 strValue = strValue.replace("$","")
No newline at end of file
54 strValue = strValue.replace("]]+++[[","]]/[[")
No newline at end of file
55 strValue = strValue.replace("]]++[[","]]/[[")
No newline at end of file
56 strValue = strValue.replace("]]+[[","]]/[[")
No newline at end of file
57 strValue = strValue.replace("],++[","],[")
No newline at end of file
58 strValue = strValue.replace("],+[","],[")
No newline at end of file
59 strValue = strValue.replace("]]+++","]]|")
No newline at end of file
60 strValue = strValue.replace("]]++","]]|")
No newline at end of file
61 strValue = strValue.replace("]]+","]]|")
No newline at end of file
62 strValue = strValue.replace(" =++[[","=[[")
No newline at end of file
63 strValue = strValue.replace("=++[[","=[[")
No newline at end of file
64 strValue = strValue.replace(" =+[[","=[[")
No newline at end of file
65 strValue = strValue.replace("=+[[","=[[")
No newline at end of file
66 strValue = strValue.replace("+","").strip()
No newline at end of file
67 #print strValue
No newline at end of file
68 lsPatterns = strValue.split("|")
No newline at end of file
69
No newline at end of file
70 return lsPatterns No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now