Skip to content

Instantly share code, notes, and snippets.

# Convirtiendo la variable dia a factor para asi manipular el orden en que se debe visualizada la variable dia
d_historico$dia <- factor( x = d_historico$dia
, levels = c('Lunes','Martes','Miercoles','Jueves','Viernes', 'Sabado','Domingo')
)
# Opcional: Revisando la estructura del factor
str( object = d_historico$dia )
library( package = 'dplyr' )
library( package = 'data.table' )
# Create vectors that will store column classes for the game and event files
l_e_cols <- c( 'character' # GAME_ID
, rep( x = 'NULL', times = 13 )
, 'character' # PIT_ID
, rep( x = 'NULL', times = 25 )
, 'numeric' # EVENT_OUTS_CT
, rep( x = 'NULL', times = 58 )
library( package = 'dplyr' )
library( package = 'data.table' )
library( package = 'reshape2' )
# Column names
l_e_names <- c( 'GAME_ID','CATCHER','FIRST_BASEMAN','SECOND_BASEMAN'
, 'THIRD_BASEMAN','SHORTSTOP','LEFT_FIELDER','CENTER_FIELDER'
, 'RIGHT_FIELDER', 'EVENT_OUTS_CT' ,'TEAM_ID'
)
library( package = 'dplyr' )
library( package = 'ggplot2' )
library( package = 'data.table' )
# Column types
l_g_cols <- c( 'NULL'
, 'character' # GAME_DT
, rep( x = 'NULL', times = 5 )
, 'character' # AWAY_TEAM_ID
, 'character' # HOME_TEAM_ID
def reverse2( self, current, previous ):
if current:
self.reverse2( previous = current
, current = current.getNext()
)
else:
return
print str(current.getData())+str('-->'),
class Nodo:
def __init__( self, dato ):
self.dato = dato
self.sig = None
#def asignarDato( self, dato ):
# self.dato = dato
def asignarSig( self, sig ):
class Nodo:
def __init__( self, dato ):
self.dato = dato
self.sig = None
#def asignarDato( self, dato ):
# self.dato = dato
def asignarSig( self, sig ):
def __init__( self ):
self.cabeza = None
self.cola = None
self.tamanio = 0
def encolar( self, dato ):
nuevoNodo = Nodo( dato )
if not self.cabeza:
nuevoNodo.asignarSig( None )
self.cabeza = nuevoNodo
else:
self.cola.asignarSig( nuevoNodo )
self.cola = nuevoNodo
from lxml import etree
import glob
import csv
# Input Files.
hipFiles = glob.glob('*hip.xml')
gameFiles = glob.glob('*data.xml')
# Output File.
csvFile = open('hitsPerGame.csv', 'wb')