Import.io doesn't find the links - import.io

I use import.io desktop extractor to extract links from this page:
http://plusaccessible.org/yakaldir/html/arts_litterature.htm
It extract only titles of links:
QuestionVoyage
forum.baroussemania.com
Saint-Martin
AmieZ
Forum Russie
Forum tourisme
Teranga Senegal - forum du Sénégal
Billet d'avion
le Maroc
But it doesn't extract the urls inside the href="".
If I add the xpath myself:
/html/body/div[1]/div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/a[1]
It give the same url for all the links
If I add
/html/body/div[1]/div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/a
It gives all the urls for each links:
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
QuestionVoyageforum.baroussemania.comSaint-MartinAmieZForum
RussieForum tourismeTeranga Senegal - forum du SénégalBillet
d'avionle MarocForum sur la GrèceInfo location de vacancesCarnet de
voyages Chris2neuXA tous les bouts du mondeRésidences de vacances
dans le monde entierAnnuaire des Hébergements - inn26.comTaxi C.
CadetLocFrance Annonces de location de vacancesLocasun - Locations
vacancesAtouts Loisirs - HolidaysHomes
So my question is how can I extract the links with url of this page?
Thanks in advance
Kind regards

It looks like you want to extract all the links on the page? If so, you can try a much simple xpath expression:
//a[#href]
That should select all <a> elements, no matter where in the page, and then extract the href attribute from them.

Related

how to loop through the nth slide powerpoint vba

I have the following code to create a progress bar in a PowerPoint presentation
Sub BarreDeProgression()
'Génère une barre de progression
'Valeurs à adapter selon besoin
Const Longueur As Single = 1 'Longueur totale de la barre (% de la longueur de la diapo (0.25 =25%))
Const Hauteur As Single = 0.02 'Hauteur totale de la barre (% de la hauteur de la diapo)
Const PositionX As Single = 0.1 'Position en X de la barre (% de la longueur de la diapo en partant de la gauche)
Const PositionY As Single = 0.05 'Position en Y de la barre (% de la hauteur de la diapo en partant de la gauche)
'Récupération des infos
Set Pres = ActivePresentation
H = Pres.PageSetup.SlideHeight
W = Pres.PageSetup.SlideWidth * Longueur
nb = Pres.Slides.Count
Counter = 1
'Pour chaque Slide
For Each SLD In Pres.Slides
'Supprime l'ancienne barre de progression
nbShape = SLD.Shapes.Count
del = 0
For a = 1 To nbShape
If Left(SLD.Shapes.Item(a - del).Name, 2) = "PB" Then
SLD.Shapes.Item(a - del).Delete
del = del + 1
End If
Next
'pose la nouvelle barre de progression
For i = 0 To nb - 1
Set OBJ = SLD.Shapes.AddShape(msoShapeChevron, (W * i / nb) + W / nb * (PositionX / 2), H * (1 - PositionY), (W / nb) * (1 - PositionX), H * Hauteur)
OBJ.Name = "PB" & i
OBJ.Line.Visible = msoFalse
If i + 1 = Counter Then
OBJ.Fill.ForeColor.RGB = RGB(156, 156, 156)
Else
OBJ.Fill.ForeColor.RGB = RGB(216, 32, 39)
End If
Next
Counter = Counter + 1
Next
End Sub
The problem is that code loops through all slide and create a progress bar in all slide, but I don't want the bar in the first, in the introduction and i the conclusion. How can I fix it ? I thought to add and if condition where I specify that the slide number should be greater than 4, but it did not work. Thanks in advance.
In the long run, you should get in the habit of declaring variables. An example in this code is Dim X As Integer. When you do this, the variable acquires the properties and methods of the declared object type. If you don't declare them, they are all variants, and the application must guess which properties and methods apply.
In this version of your code, I removed the variant variable SLD, since that will apply the code to all members of the slides collection. I replaced it with a count of the number of slides. Then I was able to come up with a conditional statement that leaves out the first 2 and the last slides. I also adjusted the calculation of the nb variable to reduce it by three. This ensures the number of shapes totals the number of slides that display the shapes.
Here's the revised code:
Sub BarreDeProgression()
Dim X As Integer
'Génère une barre de progression
'Valeurs à adapter selon besoin
Const Longueur As Single = 1 'Longueur totale de la barre (% de la longueur de la diapo (0.25 =25%))
Const Hauteur As Single = 0.02 'Hauteur totale de la barre (% de la hauteur de la diapo)
Const PositionX As Single = 0.1 'Position en X de la barre (% de la longueur de la diapo en partant de la gauche)
Const PositionY As Single = 0.05 'Position en Y de la barre (% de la hauteur de la diapo en partant de la gauche)
'Récupération des infos
Set Pres = ActivePresentation
H = Pres.PageSetup.SlideHeight
W = Pres.PageSetup.SlideWidth * Longueur
nb = Pres.Slides.Count
Counter = 1
'Pour chaque Slide
For X = 1 To Pres.Slides.Count
If X > 2 And X < (Pres.Slides.Count) Then
'Supprime l'ancienne barre de progression
nbShape = Pres.Slides(X).Shapes.Count
del = 0
For a = 1 To nbShape
If Left(Pres.Slides(X).Shapes.Item(a - del).Name, 2) = "PB" Then
Pres.Slides(X).Shapes.Item(a - del).Delete
del = del + 1
End If
Next
'pose la nouvelle barre de progression
For I = 0 To nb - 1
Set OBJ = Pres.Slides(X).Shapes.AddShape(msoShapeChevron, (W * I / (nb - 3)) + W / (nb - 3) * (PositionX / 2), H * (1 - PositionY), (W / (nb - 3)) * (1 - PositionX), H * Hauteur)
OBJ.Name = "PB" & I
OBJ.Line.Visible = msoFalse
If I + 1 = Counter Then
OBJ.Fill.ForeColor.RGB = RGB(156, 156, 156)
Else
OBJ.Fill.ForeColor.RGB = RGB(216, 32, 39)
End If
Next
Counter = Counter + 1
End If
Next X
End Sub

Create and save multiple .txt file as .csv file by using Panda data frame

I have multiple txt files which I want to use this as a data frame. I want to use headers as column names and other texts as rows. Similar text file is:
PPR-SP
FÁBIO MEIRELLES
Biografia
Profissões: Fazendeiro; Empresário
Mandatos (na Câmara dos Deputados):
Deputado(a) Federal - 1991-1995, SP, PDS, Dt. Posse: 01/02/1991.
Proposições de Autoria do Deputado
Proposições de Autoria do Deputado Transformadas em Norma Jurídica
Proposições Relatadas pelo Deputado
Proposições Relatadas Transformadas em Norma Jurídica
Licenças:
Licenciou-se do mandato de Deputado Federal, na Legislatura 1991-1995, por 13 dias, para tratamento de saúde, a partir de 01 de janeiro de 1994; por 15 dias, a partir de 30 março de 1993; por 17 dias, a partir de 14 de abril de 1993.
Atividades Parlamentares:
CÂMARA DOS DEPUTADOS - Legislaturas anteriores à 54ª:COMISSÕES PERMANENTES: Agricultura e Política Rural: Segundo Vice-Presidente, 1993, Titular, 1991-1992, e 1994; Constituição e Justiça e de Redação: Suplente, 1994; Defesa Nacional: Titular, 1991-1993, 1994, e Suplente, 1991; Economia, Indústria e Comércio: Suplente, 1991-1992; Minas e Energia: Titular 1993; COMISSÕES ESPECIAIS:Crimes de Responsabilidades do Presidente, da República: Suplente, 1992; PEC nº 56/91, Desregulamentação da Economia: Proimeiro Vice-Presidente, 1992. CPIs: Violência no Campo: Titular, 1992; COMISSÕES EXTERNAS: Para representar a Câmara dos Deputados a Câmara dos Deputados nas cerimônias fúnebres do sepultamento do desportista Aírton Senna, 1994CONGRESSO NACIONAL: Comissão Mista Que Examinou a Medida Provisória N.295/91: Membro, 1991; CPI Mista Companhia Nacional de Abastecimento: Titular, 1992.
Atividades Profissionais e Cargos Públicos:
Membro, Junta Administrativa do IBC e da Comissão de Organização de Feiras Agropecuárias do Estado de São Paulo, 1961-1967; Subchefe de Gabinete, Ministério da Agricultura 1964; Secretário Executivo, Fundo Agropecuário do Ministério da Agricultura 1964; Secretário, Comissão de Política e Planejamento Agrícola do Ministério da Agricultura, 1964; Presidente, BNCC, 1964; Presidente, Instituto do Café, SP, 1973-1979; Vice-Presidente Executivo, GEDPA, SP, 1979; Diretor de Operações Rurais e Agroindustriais, BADESP, 1979-1983; Secretaria de Agricultura e Abastecimento de São Paulo, 1986-1988..
Atividades Sindicais Representativas de Classe Associativas e Conselhos:
Presidente, Associação Rural do Vale do Sapucaí, 1960-1961; Diretor, Federação das Associações Rurais do Estado de São Paulo, 1961-1963; Presidente, Associação Rural de Franca, SP, 1962-1965; Presidente, FAESP, 1975-1978, 1978-1981, 1981-1984, 1984-1987, 1987-1990 e 1990-1993; Vice-Presidente, CNA, 1982-1985, 1985-1987 e 1987-1990; Membro, Junta Administrativa do IBC, 1961-1967; Membro, Comissão de Organização de Feiras Agropecuárias do Estado de São Paulo, 1961-1967; Membro, Junta Consultiva do IBC, 1984; Representante Classista, Confederação Nacional da Agricultura, 1984; Primeiro-Vice-Presidente, CNA, 1985-1987; Membro, UBE, 1987; Representante da FAESP junto à CNA; Título de Presidente, Associação Brasileira das Empresas Produtoras de Charque do Estado de São Paulo; Delegado Representante da FAESP junto ao CIEE.
 
 ; Conselheiro, Associação Brasileira de Exportadores do Rio de Janeiro, RJ, 1978; Membro, COPAGRI, Secretaria da Agricultura e Abastecimento de São Paulo, SP, 1986-1988; Membro, Conselho Administrativo da Companhia de Desenvolvimento Agrícola do Estado de São Paulo, 1987-1990; Membro Nato, Alto Conselho Agrícola do Estado de São Paulo; Presidente Licenciado, Conselho Administrativo do Clube da Cidade de São Paulo; Membro, Conselho Superior da Sociedade Nacional da Agrícultura e do Conselho Consultivo do Instituto Histórico e Geográfico; Conselheiro Mantenedor, CEDES; Representante da FAESP junto ao Conselho Universitário da Univ. Estadual Paulista Júlio de Mesquita Filho e a CNA junto à Câmara dos Deputados, Assessoria Especial de Assuntos Agropecuários Nacionais, 1971; Conselheiro, Fundação de Desenvolvimento da Pesquisa Agropecuária; Membro, Conselho Universitário da USP; Conselheiro, Associação GIR do Brasil; Membro, Conselho Superior da SRB e do Fórum Informal de Empresários de São Paulo.
Estudos e Cursos Diversos:
Ciências Jurídicas e Sociais, Fac. de Direito, Franca, SP, 1977; Ciclo de Estudos, ADESG; Ciclo de Extensão A Segurança Nacional no Pensamento Político Brasileiro, ESG, 1987; Diplomado, XIX Ciclo de Estudos, ADESG, 1977; II Curso de Atualização, Interpretação e Programação da Legislação Trabalhista Rural, FAESP, São Paulo, SP.
Obras Publicadas:
Melhorias das Condições de Vida dos Trabalhadores Rurais Autônomos: parceiros, Meeiros, Arrendatários e Categorias Análogas. Anais do LII Congresso Internacional da OIT, Genebra, Suíça, 1968; Café : Produção e Comercialização. In: XXX Congresso Agropecuário Brasileiro, Brasília, 1969; Agricultura no Estado de São Paulo e meio ambiente ( Chefe e relator do grupo adesguiano responsável pela execução do trabalho ) São Paulo, 1977; Utilização do Solo visando o aumento da produtividade ( Coordenador do trabalho desenvolvido pelo grupo número 2 do grupo de assessoria e participação do Governo do Estado de São Paulo - GAP) São Paulo, 1968; Agropecuária na Consituinte, Folha de São Paulo, São Paulo, 7 nov 1986. ( Artigo selecionado entre as contribuições enviadas à constituinte, publicado, posteriormente, em florilégio, pela, Fundação Petrônio Portela); Perspectivas para a agropecuária. Jornal do Commércio, Rio de Janeiro, 1987. (Edição especial comemorativa do 160 aniversário ); Autor de diversos trabalhos publicados em Jornais e Revistas de todo o País, relacionados com os temas agricultura e pecuária..
Another txt file is:
DEM-BA
FÉLIX MENDONÇA
Biografia
Data de falecimento: 26/06/2020
Profissões: Engenheiro; Construtor civil
Escolaridade: Superior
Mandatos (na Câmara dos Deputados):
Deputado(a) Federal - 1983-1987, BA, PTB, Dt. Posse: 01/02/1983; Deputado(a) Federal - (Congresso Revisor), 1991-1995, BA, PTB, Dt. Posse: 01/02/1991; Deputado(a) Federal - 1995-1999, BA, PTB, Dt. Posse: 01/02/1995; Deputado(a) Federal - 1999-2003, BA, PTB, Dt. Posse: 01/02/1999; Deputado(a) Federal - 2003-2007, BA, PTB, Dt. Posse: 01/02/2003; Deputado(a) Federal - 2007-2011, BA, PFL, Dt. Posse: 01/02/2007.
Proposições de Autoria do Deputado
Proposições de Autoria do Deputado Transformadas em Norma Jurídica
Proposições Relatadas pelo Deputado
Proposições Relatadas Transformadas em Norma Jurídica
Votações em Plenário (Legislaturas):
52
,
53
Presença em Comissões (Legislaturas):
52
,
53
Presença em Plenário (Legislaturas):
52
,
53
Licenças:
Licenciou-se do mandato de Deputado Federal, na Legislatura 2007-2011, para tratamento de saúde, por 15 dias, a partir de 23 de março de 2009, sem convocação de Suplente.
Filiações Partidárias:
PFL, 2003; DEM, 2007
Atividades Partidárias:
Vice-Líder do PTB, 1993, 1997-1999 e 2000-2003; Vice-Líder do Bloco PFL, PTB, 1995-1996; Vice-Líder do Bloco PSDB, PTB, 2001; Vice-Líder do PFL, 2005-..
Atividades Parlamentares:
CÂMARA DOS DEPUTADOS - Legislaturas anteriores à 54ª COMISSÕES PERMANENTES: Agricultura, Pecuária, Abastecimento e Desenvolvimento Rural: Suplente, 3/2005-3/2006, 3/2006, 14/2/2007-6/2/2008, 4/3/2008-2/2/2009, 4/3/2009-1/2/2010, 3/3/2010-; Agricultura e Política Rural: Presidente, Titular e Suplente; Economia, Indústria e Comércio: Suplente; Finanças e Tributação: 1º Vice-Presidente, 2º Vice-Presidente, 26/3/2008-4/3/2009, Terceiro Vice-Presidente, 4/3/2009-3/3/2010, Titular, 3/2005-3/2006, 3/2006, 14/2/2007-6/2/2008, 4/3/2008-2/2/2009, 4/3/2009-1/2/2010, 3/3/2010-, e Suplente; Minas e Energia: Titular; Segurança Pública e Combate ao Crime Organizado: Suplente, 13/3/2008-19/11/2008; Seguridade Social e Família: Suplente. COMISSÕES ESPECIAIS: Amenizar Tributação Cumulativa: Suplente; Crimes de Responsabilidade do Presidente da República: Suplente; PEC nº 1/95, Reeleição: Titular e Suplente; PEC nº 4/95, Concessão e Distribuição do Gás Canalizado: Suplente; PEC nº 40/03, Reforma da Previdência: Suplente-; PEC nº 53/99, Sistema Financeiro: Titular e Suplente; PEC nº 57/99, Fundo Nacional Desenvolvimento Semi-Árido: Titular; PEC nº 81/95, Cria Imposto sobre Distribuição de Combustíveis: Titular; PEC nº 175/95, Altera o Capítulo do Sistema Tributário Nacional: Titular; PEC nº 256/95, Competência à União para Instituir Contribuição Provisória sobre Movimentação Financeira: Titular; PEC nº 285/08, Fundos Habitação de Interesse Social: Titular, 6/8/2009-; PEC nº 347/96, Posse do Presidente da República: Titular; PEC nº 358/05, Reforma do Judiciário: Titular, 1/2006-; PEC nº 407/01, Prorrogação da CPMF: Titular; PEC nº 443/09, Remuneração Advogados Públicos: Titular, 1/6/2010-; PEC nº 472/97, Altera Arts. 48, 62 e 84, Edição de Medida Provisória: Suplente; PEC nº 534/02, Guardas Municipais: Titular-; PEC nº 598/98, Idade Mínima para Cargo Eletivo: Suplente; PEC nº 603/98, Terrenos da Marinha: Titular, 3/2006-; PEC nº 618/98, Patrimônio Genético: Suplente; PL nº 824/91, Propriedade Industrial: Titular; PL nº 1.210/95, Política Nacional do Petróleo: Suplente; PL nº 4.874/01, Estatuto do Desporto: Titular; Política Nacional de Habitação: Titular; PLP nº 18/99, Responsabilidade Fiscal: Titular; Projeto em Trâmite Sistema Financeiro Nacional: Titular; Projetos de Lei Legislação Tributária: Titular; Reforma da Previdência: Titular-; Questão do Desemprego: Titular e Suplente; Seca no Nordeste e Atendimento às Populações Atingidas: Suplente. COMISSÕES EXTERNAS: Fiscalização dos Atos do Executivo: Suplente. CPIs: Fuga de Capital e Evasão de Divisas do Brasil: Titular.CONSELHOS: Conselho de Altos Estudos e Avaliação Tecnológica - Trabalho sobre a Dívida Pública do Brasil: Titular; de Altos Estudos e Avaliação Tecnológica - Série Cadernos de Altos Estudos: 1-Biodiesel e Inclusão Social; 2- A Dívida Pública Brasileira (Relator); 3- O Mercado de Software no Brasil; 4- Capacitação Tecnológica da População; 5- Os Desafios do Pré-Sal; 6- Alternativas de Políticas Públlicas para a Banda Larga.GRUPOS DE TRABALHO: Transposição do Rio São Francisco.CONGRESSO NACIONALCOMISSÕES MISTAS: Planos, Orçamentos Públicos e Fiscalização: Relator Setorial do Orçamento, Área da Fazenda e Desenvolvimento, 2002 e Área da Previdência Assistência Social e Trabalho, 2003; CPMI Sistema Financeiro de Habitação: Suplente.
Mandatos Externos:
Prefeito(a) , BA, Período: 1963 a 1966; Deputado(a) Estadual , BA, Partido: ARENA, Período: 1967 a 1971.
Atividades Profissionais e Cargos Públicos:
Auxiliar de Engenharia, Secretaria de Agricultura do Estado da Bahia, 1950-1969; Engenheiro de Obras, Companhia Comercial Construtora Delta Ltda., Ilhéus, BA, 1956-1969; Engenheiro-Residente, Terraplenagem do DERBA, 1960-1961; Secretário de Obras Públicas, Prefeitura Municipal, Itabuna, BA, 1961-1962; Chefe do Departamento de Obras Industriais, CONSTROL - Comércio e Indústria de Construção, Salvador, BA, 1972-1975; Engenheiro de Produção, Santa Helena Incorporações e Construções S.A.; Consultor da MRM - Construções e Incorporações S.A., 1990..
Estudos e Cursos Diversos:
Engenharia Civil, UFBA, Salvador, 1951-1955..
I scraped documents from a website. However, when I wanted to scrape text file from header to header, I notice that div and p places are differs from link to link. I needed to scrape many links of website. However, since div and p info changes from link to link I had to download whole text. However, I need to convert these all files into datframe and save as .csv file. what I want to do for all txt files is to create dataframe like:
col(Name) -> row(FÁBIO MEIRELLES)
col(Mandatos (na Câmara dos Deputados))-> row(Deputado(a) Federal - 1983-1987, BA, PTB, Dt. Posse: 01/02/1983; Deputado(a) Federal - (Congresso Revisor), 1991-1995, BA, PTB, Dt. Posse: 01/02/1991; Deputado(a) Federal - 1995-1999, BA, PTB, Dt. Posse: 01/02/1995; Deputado(a) Federal - 1999-2003, BA, PTB, Dt. Posse: 01/02/1999; Deputado(a) Federal - 2003-2007, BA, PTB, Dt. Posse: 01/02/2003; Deputado(a) Federal - 2007-2011, BA, PFL, Dt. Posse: 01/02/2007.)
col(Licenças)-> row(Licenciou-se do mandato de Deputado Federal, na Legislatura 2007-2011, para tratamento de saúde, por 15 dias, a partir de 23 de março de 2009, sem convocação de Suplente.)
col(Filiações Partidárias)-> row(PFL, 2003; DEM, 2007)
col(Atividades Partidárias)-> row(Vice-Líder do PTB, 1993, 1997-1999 e 2000-2003; Vice-Líder do Bloco PFL, PTB, 1995-1996; Vice-Líder do Bloco PSDB, PTB, 2001; Vice-Líder do PFL, 2005-..)
col(Atividades Parlamentares)-> row(CÂMARA DOS DEPUTADOS - Legislaturas anteriores à 54ª COMISSÕES PERMANENTES: Agricultura, Pecuária, Abastecimento e Desenvolvimento Rural: Suplente, 3/2005-3/2006, 3/2006, 14/2/2007-6/2/2008, 4/3/2008-2/2/2009, 4/3/2009-1/2/2010, 3/3/2010-; Agricultura e Política Rural: Presidente, Titular e Suplente; Economia, Indústria e Comércio: Suplente; Finanças e Tributação: 1º Vice-Presidente, 2º Vice-Presidente, 26/3/2008-4/3/2009, Terceiro Vice-Presidente, 4/3/2009-3/3/2010, Titular, 3/2005-3/2006, 3/2006, 14/2/2007-6/2/2008, 4/3/2008-2/2/2009, 4/3/2009-1/2/2010, 3/3/2010-, e Suplente; Minas e Energia: Titular; Segurança Pública e Combate ao Crime Organizado: Suplente, 13/3/2008-19/11/2008; Seguridade Social e Família: Suplente. COMISSÕES ESPECIAIS: Amenizar Tributação Cumulativa: Suplente; Crimes de Responsabilidade do Presidente da República: Suplente; PEC nº 1/95, Reeleição: Titular e Suplente; PEC nº 4/95, Concessão e Distribuição do Gás Canalizado: Suplente; PEC nº 40/03, Reforma da Previdência: Suplente-; PEC nº 53/99, Sistema Financeiro: Titular e Suplente; PEC nº 57/99, Fundo Nacional Desenvolvimento Semi-Árido: Titular; PEC nº 81/95, Cria Imposto sobre Distribuição de Combustíveis: Titular; PEC nº 175/95, Altera o Capítulo do Sistema Tributário Nacional: Titular; PEC nº 256/95, Competência à União para Instituir Contribuição Provisória sobre Movimentação Financeira: Titular; PEC nº 285/08, Fundos Habitação de Interesse Social: Titular, 6/8/2009-; PEC nº 347/96, Posse do Presidente da República: Titular; PEC nº 358/05, Reforma do Judiciário: Titular, 1/2006-; PEC nº 407/01, Prorrogação da CPMF: Titular; PEC nº 443/09, Remuneração Advogados Públicos: Titular, 1/6/2010-; PEC nº 472/97, Altera Arts. 48, 62 e 84, Edição de Medida Provisória: Suplente; PEC nº 534/02, Guardas Municipais: Titular-; PEC nº 598/98, Idade Mínima para Cargo Eletivo: Suplente; PEC nº 603/98, Terrenos da Marinha: Titular, 3/2006-; PEC nº 618/98, Patrimônio Genético: Suplente; PL nº 824/91, Propriedade Industrial: Titular; PL nº 1.210/95, Política Nacional do Petróleo: Suplente; PL nº 4.874/01, Estatuto do Desporto: Titular; Política Nacional de Habitação: Titular; PLP nº 18/99, Responsabilidade Fiscal: Titular; Projeto em Trâmite Sistema Financeiro Nacional: Titular; Projetos de Lei Legislação Tributária: Titular; Reforma da Previdência: Titular-; Questão do Desemprego: Titular e Suplente; Seca no Nordeste e Atendimento às Populações Atingidas: Suplente. COMISSÕES EXTERNAS: Fiscalização dos Atos do Executivo: Suplente. CPIs: Fuga de Capital e Evasão de Divisas do Brasil: Titular.CONSELHOS: Conselho de Altos Estudos e Avaliação Tecnológica - Trabalho sobre a Dívida Pública do Brasil: Titular; de Altos Estudos e Avaliação Tecnológica - Série Cadernos de Altos Estudos: 1-Biodiesel e Inclusão Social; 2- A Dívida Pública Brasileira (Relator); 3- O Mercado de Software no Brasil; 4- Capacitação Tecnológica da População; 5- Os Desafios do Pré-Sal; 6- Alternativas de Políticas Públlicas para a Banda Larga.GRUPOS DE TRABALHO: Transposição do Rio São Francisco.CONGRESSO NACIONALCOMISSÕES MISTAS: Planos, Orçamentos Públicos e Fiscalização: Relator Setorial do Orçamento, Área da Fazenda e Desenvolvimento, 2002 e Área da Previdência Assistência Social e Trabalho, 2003; CPMI Sistema Financeiro de Habitação: Suplente.)
col(Mandatos Externos) -> row(Prefeito(a) , BA, Período: 1963 a 1966; Deputado(a) Estadual , BA, Partido: ARENA, Período: 1967 a 1971.
col(Atividades Profissionais e Cargos Públicos) -> row(
Auxiliar de Engenharia, Secretaria de Agricultura do Estado da Bahia, 1950-1969; Engenheiro de Obras, Companhia Comercial Construtora Delta Ltda., Ilhéus, BA, 1956-1969; Engenheiro-Residente, Terraplenagem do DERBA, 1960-1961; Secretário de Obras Públicas, Prefeitura Municipal, Itabuna, BA, 1961-1962; Chefe do Departamento de Obras Industriais, CONSTROL - Comércio e Indústria de Construção, Salvador, BA, 1972-1975; Engenheiro de Produção, Santa Helena Incorporações e Construções S.A.; Consultor da MRM - Construções e Incorporações S.A., 1990..)
col(Estudos e Cursos Diversos)-> row(Engenharia Civil, UFBA, Salvador, 1951-1955..)
I am trying to fins a code to see same headers in all .txt files and save them as .csv file.
Thanks in advance!
The question is not very clear in parts and the example files do not have much structure to them. See the code below as an example and do note that getting the Name looks a bit weak to me (though it does seem to work for the example files).
Apologies if there is something obviously wrong in the output. I cannot speak Portuguese so I did not look too hard at the exact words.
Maybe:
import pandas as pd
import glob
# given the columns should be (actually this is a
# list of what to look for in the files)...
cols = ['Name',
'Mandatos (na Câmara dos Deputados',
'Licenças',
'Filiações Partidárias',
'Atividades Partidárias',
'Atividades Parlamentares',
'Mandatos Externos',
'Atividades Profissionais e Cargos Públicos',
'Estudos e Cursos Diversos']
def getLines(file):
'''
Function to take a text file and return a list of cleaned non-blank lines
'''
with open(file, 'r') as f_in:
lines = (line.strip() for line in f_in)
lines = list(line for line in lines if line)
return lines
def createFrame(lines):
'''
Function to take a list and return a dataframe
'''
d = {}
for ln, l in enumerate(lines):
# for lines matches any item in the 'cols' list
if any(c in l for c in cols):
# add that line to the dict with the value as the next line
d[l[:-1]] = [lines[ln+1]]
# really weak way of find the 'Name' - if ALL CAPS and there is a space
# and it is in the first ten lines
elif l.isupper() and ' ' in l and ln < 10:
# add the name to the dict
d['Name'] = [l]
return pd.DataFrame(d)
# set a path to a folder of all these text files
path = r'./text_files/' # use your path
all_files = glob.glob(path + '/*.txt')
# create a list for all the frame we're about to create
dfs = []
# loop through all the files in the set folder
for file in all_files:
# use the functions to clean the files, get a list,
# create a dictionary and then return a frame
dfs.append(createFrame(getLines(file)))
# concat the frames together (assume this is required?)
df = pd.concat(dfs).reset_index(drop=True)
# output the dataframe to a CSV file
df.to_csv('out.csv', index=False)
print('Done.')
display(df)
Output:
CSV:

Translation from maple to sql?

okay, so I have this piece of code that I have made on the software MAPLE and I need to tranform the code into the sql language (on oracle). I'd be really thankful if any of you could help me or maybe even just point out some applications, websites to achieve this. I have a table in whih there are listed parents and their respective children and the code is supposed to create another table with aunt, uncles and their nieces.
heres the code:
`use DocumentTools,Statistics,ListTools in
#Matrice=tabella
M:=Matrix([l,m]);
#nulla di importante, solo per la resa grafica
SetProperty('m',visibleRows,2);
SetProperty('m',visibleColumns,Count(m));
inta:=[];
for i from 1 to Count(m) do
inta:=[inta[],300];
end;
SetProperty('m',rowNames,["genitori","figli"]);
SetProperty('m',columnWidths, inta);
SetProperty('m',update);
#inizializzazione di liste
p:=[];
zii:=[];
nipoti:=[];
#m è una lista formata da sotto liste, per usare il comando del pacchetto(libreria) ListTools, Search, devo trasformarla in una lista unica
for j from 1 to Count(m) do
p:=[p[],op(m[j])];
end do;
#l è anche una lista di liste, dunque 2 cicli per selezionare ogni elemento
for k from 1 to Count(l) do
for K from 1 to Count(l[k]) do
#se un figlio è anche un genitore, allora in quella famiglia ci sono nipoti e ci possono essere zii. Controllo se un padre è anche figlio
s:=Search(l[k][K],p);
if s=0 then
else
#Se lo fosse individuo la lista che lo contiene in quelle dei figli
for jj from 1 to Count(m) do
num:=Search(p[s],m[jj]);
if num=0 then
else
lista_n:=[];
for cont from 1 to Count(m[jj]) do
if m[jj][cont]=p[s] then
#Tramite l'if escludo dalla lista il genitore
else
lista_n:=[lista_n[],m[jj][cont]];
end if;
end do;
zii:=[zii[],lista_n];
end if;
end do;
#I nipoti sono in posizione uguale al genitore, ma nell'altra lista
nipoti:=[nipoti[],m[k]];
end if;
end; end;
#i succesivi for e if servono nel caso in cui ci siano zii da entrambi i genitori
for lol from 2 to Count(nipoti) do
if nipoti[lol]=nipoti[lol-1] then
#i nipoti comuni sono consecutivi poichè i genitori originali lo erano nella lista ordinata (spero che si capisca cosa voglio dire).
#Dunque inserisco una lista nell 'altra e elimina quella stessa lista ridifinendola e utilizzando un if e un for
zii[lol]:=[op(zii[lol]),op(zii[lol-1])];
zii[lol-1]:=[elimina];
else
end if;
Zii:=[];
for contatore from 1 to Count(zii) do
if zii[contatore]=[elimina] then
else
Zii:=[Zii[],zii[contatore]];
end if;
end;
end;
#Nulla di importante per il codice, apparte il comando MakeUnique che elimina i doppioni (dovrebbe essere superfluo ma non ho più testato).
inta1:=[];
for i from 1 to max([Count(zii),Count(nipoti)]) do
inta1:=[inta1[],300];
end;
DataTable:=Matrix([MakeUnique(Zii),MakeUnique(nipoti)]);
SetProperty('T',visibleColumns,max([Count(zii),Count(nipoti)]));
SetProperty('T',visibleRows,2);
SetProperty('T',columnWidths, inta1);
SetProperty('T',rowNames,["zii","nipoti"]);
SetProperty('T',update);
`
It should not be complex to translate this code into PL/SQL that is a complete programming language so should be capable of doing everything. You can implement it as a stored procedure and later access it also from SQL statements.
If there are some mathematical constructs, I suggest to use Maple code generation feature, producing the code of some not too specific language (even C or FORTRAN may do) that can be later converted into PL/SQL by hand. However the code as it is seems having no any complex mathematical features, while I would obviously understand it much more completely be the comments in English and not Italian.

How to Replace a specific char in a Varchar2 on Select

I have a VARCHAR2 that I want to Select, but it's too long. So, I want to Split it into multiples lines like this.
SELECT 'Veuillez adresser toute la correspondance à : Aktiva2 Service Comptabilité : 30 B rue de la Petite Hollande 59700 Marcq-en-Baroeul Tel : 03 20 20 34 83#RET#IMPORTANT: pour faciliter nos échanges comptables, lors de votre paiement, par chèque et en particulier par virement, merci de rappeler votre n° de client et n° de facture acquittée.#RET##RET#Paiement comptant sans escompte même en cas de paiement anticipé. Au-delà de 10 jours, une pénalité de 3 fois le taux d''intérêt légal (Loi 2008-776 du 04 août 2008) sera appliquée, calculée au prorata temporis sur la valeur de facture. #RET##RET#Conforment à la loi du 29 février 2012 le montant de l''indemnité forfaitaire pour frais de recouvrement est de 40 euros dans le cas où les sommes dues sont réglées après la date de règlement figurant sur la facture.'
FROM dual
Now I want to replace #RET# with something to jump into a 'new line' here. The result must be like this:
Veuillez adresser toute la correspondance à : Aktiva2 Service Comptabilité : 30 B rue de la Petite Hollande 59700 Marcq-en-Baroeul Tel : 03 20 20 34 83
IMPORTANT: pour faciliter nos échanges comptables, lors de votre paiement, par chèque et en particulier par virement, merci de rappeler votre n° de client et n° de facture acquittée.
Paiement comptant sans escompte même en cas de paiement anticipé. Au-delà de 10 jours, une pénalité de 3 fois le taux d''intérêt légal (Loi 2008-776 du 04 août 2008) sera appliquée, calculée au prorata temporis sur la valeur de facture.
<p>Conforment à la loi du 29 février 2012 le montant de l''indemnité forfaitaire pour frais de recouvrement est de 40 euros dans le cas où les sommes dues sont réglées après la date de règlement figurant sur la facture.
you can try something like this
declare text varchar2(1000);
begin
SELECT 'Veuillez adresser toute la correspondance à : Aktiva2 Service Comptabilité : 30 B rue de la Petite Hollande 59700 Marcq-en-Baroeul Tel : 03 20 20 34 83#RET#IMPORTANT: pour faciliter nos échanges comptables, lors de votre paiement, par chèque et en particulier par virement, merci de rappeler votre n° de client et n° de facture acquittée.#RET##RET#Paiement comptant sans escompte même en cas de paiement anticipé. Au-delà de 10 jours, une pénalité de 3 fois le taux d''intérêt légal (Loi 2008-776 du 04 août 2008) sera appliquée, calculée au prorata temporis sur la valeur de facture. #RET##RET#Conforment à la loi du 29 février 2012 le montant de l''indemnité forfaitaire pour frais de recouvrement est de 40 euros dans le cas où les sommes dues sont réglées après la date de règlement figurant sur la facture.'
into text from dual;
select REPLACE(text,'#RET#',chr(10)) into text from dual;
insert into testtable (col_text) values(text);
end;
/
This select will place spaces
select REPLACE(text,'#RET#',chr(10)) into text from dual;
CHR(10) is a new line
so REPLACE(text,'#RET#',chr(10))
cheers
You can use the SQL function REPLACE:
replace(your_column, '#RET#', chr(13) || chr(10))
13 and 10 are the ASCII codes for CR and LF.
You could use REPLACE. It depends on your OS whether to use only CHR(10) or both CHR(10) and CHR(13).
CHR(10) - Line feed
CHR(13) - Carriage return.
For windows:
chr(10) || chr(13)
For most of other OS:
chr(10)
For example, in my windows machine:
SQL> set linesize 100
SQL> WITH DATA AS(
2 SELECT 'Veuillez adresser toute la correspondance à : Aktiva2 Service Comptabilité : 30 B rue de la Petite Hollande 59700 Marcq-en-Baroeul Tel : 03 20 20 34 83#RET#IMPORTANT: pour faciliter nos échanges comptables,
lors de votre paiement, par chèque et en particulier par virement, merci de rappeler votre n° de client et n° de facture acquittée.#RET##RET#Paiement comptant sans escompte même en cas de paiement anticipé. Au-delà de 1
0 jours, une pénalité de 3 fois le taux d''intérêt légal (Loi 2008-776 du 04 août 2008) sera appliquée, calculée au prorata temporis sur la valeur de facture. #RET##RET#Conforment à la loi du 29 février 2012 le montant
de l''indemnité forfaitaire pour frais de recouvrement est de 40 euros dans le cas où les sommes dues sont réglées après la date de règlement figurant sur la facture.' str
3 FROM dual
4 )
5 SELECT REPLACE(str, '#RET#', chr(10)) text FROM DATA;
TEXT
----------------------------------------------------------------------------------------------------
Veuillez adresser toute la correspondance à : Aktiva2 Service Comptabilité : 30 B rue de la Petite
Hollande 59700 Marcq-en-Baroeul Tel : 03 20 20 34 83
IMPORTANT: pour faciliter nos échanges comptables, lors de votre paiement, par chèque et en particul
ier par virement, merci de rappeler votre n° de client et n° de facture acquittée.
Paiement comptant sans escompte même en cas de paiement anticipé. Au-delà de 10 jours, une pénalité
de 3 fois le taux d'intérêt légal (Loi 2008-776 du 04 août 2008) sera appliquée, calculée au prorata
temporis sur la valeur de facture.
Conforment à la loi du 29 février 2012 le montant de l'indemnité forfaitaire pour frais de recouvrem
ent est de 40 euros dans le cas où les sommes dues sont réglées après la date de règlement figurant
sur la facture.
SQL>

replace a word (its appears twice) i need replace the last. sql

they are my rows
Número Total de Clientes
Número Total de Clientes de
Número Total de Líquidos que se Consumen en el Hogar a la Semana
Número Total de Líquidos que se Consumen en el Hogar a la Semana de
Número Total de garrafones de
Número Total de garrafones en el mercado
Númeto Total de garrafones de
Porcentaje Clientes que Compran por Calidad
Porcentaje Clientes que Compran por Disponibilidad
Porcentaje Clientesque Compran por Otros Motivos
Porcentaje Clientesque Compran por Precio
Porcentaje Total de garrafones de
Porcentaje de Clientes
Porcentaje de Clientes xxxx que Compran en la Ruta Hogar
Porcentaje de Clientes de
Porcentaje de Participación de Ventas de
Porcentaje de garrafones de
my table is named #ope_censo_indicador
you could see i have those
Número Total de Clientes
Número Total de Clientes de
i need it was
Número Total de Clientes marca
but i got
Número Total de Clientes
Número Total marcaClientes marca
with this query
update #ope_censo_indicador set ope_indicadoridname=(replace(ope_indicadoridname,'%de','%marca'))
where ope_indicadoridname like '% de'
with these too
Número Total de Líquidos que se Consumen en el Hogar a la Semana
Número Total de Líquidos que se Consumen en el Hogar a la Semana de
i need it return
Número Total de Líquidos que se Consumen en el Hogar a la Semana
Número Total de Líquidos que se Consumen en el Hogar a la Semana marca
this too
Porcentaje de Clientes Porcentaje de Clientes Cristal que Compran en
la Ruta Hogar Porcentaje de Clientes de
i need return
Porcentaje de Clientes Porcentaje de Clientes Cristal que Compran en
la Ruta Hogar Porcentaje de Clientes marca
( i have more but it would great i got it with one query)
after it, i'll have.
Número Total de Clientes
Número Total de Clientes marca
Número Total de Líquidos que se Consumen en el Hogar a la Semana
Número Total de Líquidos que se Consumen en el Hogar a la Semana marca
Número Total de garrafones marca
Número Total de garrafones en el mercado
Porcentaje Clientes que Compran por Calidad
Porcentaje Clientes que Compran por Disponibilidad
Porcentaje Clientesque Compran por Otros Motivos
Porcentaje Clientesque Compran por Precio
Porcentaje Total de garrafones marca
Porcentaje de Clientes
Porcentaje de Clientes xxxx que Compran en la Ruta Hogar
Porcentaje de Clientes marca
Porcentaje de Participación de Ventas marca
Porcentaje de garrafones marca
i am going to want to delete those (or to do a query with a distinct but i'll need return this:)
Número Total de Clientes marca
Número Total de Líquidos que se Consumen en el Hogar a la Semana marca
Número Total de garrafones marca
Número Total de garrafones en el mercado
Porcentaje Clientes que Compran por Calidad
Porcentaje Clientes que Compran por Disponibilidad
Porcentaje Clientesque Compran por Otros Motivos
Porcentaje Clientesque Compran por Precio
Porcentaje Total de garrafones marca
Porcentaje de Clientes xxxx que Compran en la Ruta Hogar
Porcentaje de Clientes marca
Porcentaje de Participación de Ventas marca
Porcentaje de garrafones marca
enter code here
This was tricky! I am assuming you are basically saying you want to replace the LAST "de" with "marca" but only if it is the LAST word. If it is in the middle you want to leave it alone.
If that is correct, this code handles it:
-- Setup a temp table with "bigstring" as your text and "lastpos" as the location of LAST "de"
DECLARE #tmp1 TABLE (bigstring varchar(1000), lastpos int)
INSERT INTO #tmp1 (bigstring) VALUES ('Número Total de Líquidos que se Consumen en el Hogar a la Semana')
INSERT INTO #tmp1 (bigstring) VALUES ('Número Total de Líquidos que se Consumen en el Hogar a la Semana de')
INSERT INTO #tmp1 (bigstring) VALUES ('Leave this de one alone')
-- Ensure we don't have any trailing spaces
UPDATE #tmp1 SET bigstring = RTRIM(bigstring)
-- If the string ENDS in ' de' then record the starting position of that word
UPDATE #tmp1 SET lastpos = LEN(bigstring)-2 WHERE RIGHT(bigstring,3) = ' de'
-- Here is how our table looks now
SELECT * from #tmp1
-- Now, if LASTPOS is not null, we want everything to the LEFT of that + 'marca'
UPDATE #tmp1 SET bigstring = SUBSTRING(bigstring, 1, lastpos) + 'marca' WHERE lastpos IS NOT NULL
-- Done!
SELECT * from #tmp1
Your first string was left alone, the second has the final "de" replaced with "marca" and the one I put in there (with "de" in the middle) was left alone.
I hope that helps!