Reasonable tool to convert a spreadsheet to text, with one row = one page











up vote
0
down vote

favorite












I've been looking for various ways to convert a spreadsheet (let's say CSV) into a multi-page marked up textfile (PDF, Word, LaTeX, ... ), where one line becomes one page; I'd rather not deal with HTML but that might be a small step too.



Speaking in HTML pseudocode, say for example column A contains titles, B authors, C summaries (as HTML text?), D some metadata, and indicating as $B$i the cell content of column B row i, then I want row i to output page i as the appropriate equivalent of:



<h2>($A$)</h2>
<h3>by ($B$i)</h3>
($C$i)
<div class="metadata">($D$i)</div>
<hr class="newpage-marker/>


All the possibilities I've come across seem to be interested in keeping the tabular data tabular. Maybe there's nothing pre-existing? I need PDF but I've never worked with it (nor PostScript), so I'm mostly thinking of detours via LaTeX or Word. Am I overlooking something practical?










share|improve this question
























  • You could just use a letter mailmerge, with mergefields between your HTML tags. That will generate one page per record. Saving the output as a PDF may well suffice. For the basics, see: support.office.com/en-us/article/…
    – macropod
    Nov 20 at 5:38















up vote
0
down vote

favorite












I've been looking for various ways to convert a spreadsheet (let's say CSV) into a multi-page marked up textfile (PDF, Word, LaTeX, ... ), where one line becomes one page; I'd rather not deal with HTML but that might be a small step too.



Speaking in HTML pseudocode, say for example column A contains titles, B authors, C summaries (as HTML text?), D some metadata, and indicating as $B$i the cell content of column B row i, then I want row i to output page i as the appropriate equivalent of:



<h2>($A$)</h2>
<h3>by ($B$i)</h3>
($C$i)
<div class="metadata">($D$i)</div>
<hr class="newpage-marker/>


All the possibilities I've come across seem to be interested in keeping the tabular data tabular. Maybe there's nothing pre-existing? I need PDF but I've never worked with it (nor PostScript), so I'm mostly thinking of detours via LaTeX or Word. Am I overlooking something practical?










share|improve this question
























  • You could just use a letter mailmerge, with mergefields between your HTML tags. That will generate one page per record. Saving the output as a PDF may well suffice. For the basics, see: support.office.com/en-us/article/…
    – macropod
    Nov 20 at 5:38













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've been looking for various ways to convert a spreadsheet (let's say CSV) into a multi-page marked up textfile (PDF, Word, LaTeX, ... ), where one line becomes one page; I'd rather not deal with HTML but that might be a small step too.



Speaking in HTML pseudocode, say for example column A contains titles, B authors, C summaries (as HTML text?), D some metadata, and indicating as $B$i the cell content of column B row i, then I want row i to output page i as the appropriate equivalent of:



<h2>($A$)</h2>
<h3>by ($B$i)</h3>
($C$i)
<div class="metadata">($D$i)</div>
<hr class="newpage-marker/>


All the possibilities I've come across seem to be interested in keeping the tabular data tabular. Maybe there's nothing pre-existing? I need PDF but I've never worked with it (nor PostScript), so I'm mostly thinking of detours via LaTeX or Word. Am I overlooking something practical?










share|improve this question















I've been looking for various ways to convert a spreadsheet (let's say CSV) into a multi-page marked up textfile (PDF, Word, LaTeX, ... ), where one line becomes one page; I'd rather not deal with HTML but that might be a small step too.



Speaking in HTML pseudocode, say for example column A contains titles, B authors, C summaries (as HTML text?), D some metadata, and indicating as $B$i the cell content of column B row i, then I want row i to output page i as the appropriate equivalent of:



<h2>($A$)</h2>
<h3>by ($B$i)</h3>
($C$i)
<div class="metadata">($D$i)</div>
<hr class="newpage-marker/>


All the possibilities I've come across seem to be interested in keeping the tabular data tabular. Maybe there's nothing pre-existing? I need PDF but I've never worked with it (nor PostScript), so I'm mostly thinking of detours via LaTeX or Word. Am I overlooking something practical?







scripting pagination ms-word latex spreadsheet






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 at 10:40

























asked Nov 19 at 17:17









user3445853

1105




1105












  • You could just use a letter mailmerge, with mergefields between your HTML tags. That will generate one page per record. Saving the output as a PDF may well suffice. For the basics, see: support.office.com/en-us/article/…
    – macropod
    Nov 20 at 5:38


















  • You could just use a letter mailmerge, with mergefields between your HTML tags. That will generate one page per record. Saving the output as a PDF may well suffice. For the basics, see: support.office.com/en-us/article/…
    – macropod
    Nov 20 at 5:38
















You could just use a letter mailmerge, with mergefields between your HTML tags. That will generate one page per record. Saving the output as a PDF may well suffice. For the basics, see: support.office.com/en-us/article/…
– macropod
Nov 20 at 5:38




You could just use a letter mailmerge, with mergefields between your HTML tags. That will generate one page per record. Saving the output as a PDF may well suffice. For the basics, see: support.office.com/en-us/article/…
– macropod
Nov 20 at 5:38












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










The following LaTeX code takes a CSV as input and outputs a single page per row based on the content within the input file.



enter image description here



documentclass{article}

usepackage{filecontents}
% https://www.powells.com/25-books-to-read-before-you-die
begin{filecontents*}{file.csv}
Number,Title,Author,Summary,Metadata
1,2666,Roberto Bolano,"Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the ""total novel,"" 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.","7, 98213"
2,All About Love,Bell Hooks,"We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.","1, 75014"
3,Desert Solitaire,Edward Abbey,"No author encapsulated and celebrated the American Southwest more engagingly than iconoclast and raconteur Edward Abbey. Desert Solitaire: A Season in the Wilderness - now nearly a half-century old - is a classic of environmental writing. In this autobiographical work, Abbey chronicles his time as a park ranger and reflects on landscape, culture, politics, tourism, environmental disregard, and degradation - doing so with a unique blend of ornery charm and breathtaking description. Though set in his beloved Southwest, Desert Solitaire beautifully and brashly captures the essence of the American outdoors, replete with disdain for those who'd seek to spoil its natural wonder.","10, 57475"
4,Disgrace,JM Coetzee,"One afternoon while talking with a friend about books, I wondered how to best describe my experience of reading Disgrace, and this is what I came up with: it's like a finely crafted, very sharp knife resting gently against your skin. The uneasiness and suspense are there from the beginning, made all the more powerful by Coetzee's control and use of spare language, and you never really take a deep breath until it's all over. Set in modern South Africa, the book explores what it's like to personally confront deep prejudices. Prejudices of gender, sexuality, class, and race. Far from being a politically correct diatribe, this novel is about how we cope, how we survive as humans, and it forces the reader to reflect upon what seems at first a very twisted reality. For each of the characters in this astonishing novel, redemption is attained through what becomes the very reshaping of their souls.","4, 3245"
5,Geek Love,Katherine Dunn,"This is the book I recommend more than any other - I can barely hold onto a copy of it because I am always giving it away to anyone who I think needs something that will blow the top of their skull off. On one level, it is the engaging, creepy, and extraordinary story of a family of purposely designed circus freaks, as told by the hunchback albino dwarf sister. On another level, it is a story about identity and belonging: How do you define yourself in terms of your family? Your culture? Your body? Your religion? How do you know what or who you really are?","74, 87170"
6,Gilead,Marilynne Robinson,"Set in 1956, Marilynne Robinson's Gilead is a letter from the elderly Reverend John Ames to his very young son. Ames has lived all of his life in Gilead, Iowa, and the novel delves into the history of the area through the characters of Ames's father and grandfather - also ministers, but deeply divided on ideas such as pacifism, duty, and the abolitionist movement. And eventually, when John Ames Boughton, Ames's namesake and godson, returns to Gilead, he brings up old tensions and sets events in motion that disturb Ames's formerly peaceful last days. Gilead is one of the most beautifully written books of the new century thus far, and Robinson's incredibly insightful grappling with faith, mortality, and what constitutes a meaningful life will resonate with readers across every spectrum.","88, 81905"
7,Giovanni's Room,James Baldwin,"It would be difficult to talk about James Baldwin's Giovanni's Room and not touch on the simple fact that this slim novel, published in 1956, is mainly a love story between two men. It seems impossible to think such a thing could be published pre-Stonewall, but such is the genius of Baldwin and the way he captures the complexities of desire, love, and the tragic cost that comes from not following your heart. ""Somebody…should have told us that not many people have ever died of love. But multitudes have perished…for the lack of it."" This emotional wonder of a book comes down to two things: love and death. And really, what else is there in life?","6, 53009"
8,A Good Man Is Hard To Find and Other Stories,Flannery O'Connor,"Flannery O'Connor's first short story collection, written in 1955, will knock you off your feet. Ruthless, penetrating, and loaded with subtext, A Good Man Is Hard to Find and Other Stories was brave for its time and feels just as consequential today. Writing in the Southern Gothic tradition in a style wholly her own, O'Connor creates characters that are misguided, stunted curiosities, but she manages to capture what's human in even the most despicable of people - which makes their doomed trajectories feel all the more tragic. And despite the disturbing events that unfold, the stories are a pleasure to read - they're infused with suspense, dark humor, and some of the most evocative imagery you'll encounter in literature. All this makes for a collection that never ceases to amaze - and begs to be reread.","40, 73776"
9,The Handmaid's Tale,Margaret Atwood,"Atwood's classic dystopian novel of a terrifying (and terrifyingly plausible) future America has rewarded rereading like no other book; I've probably read it 30 times by now. The world of the narrator, Offred (from ""Of Fred"" - women no longer have their own names), is chilling, but she is a magnificent survivor and chronicler, and the details of everything from mundane daily life to ritualized sex and violence to her reminiscences of the time before (our contemporary reality, as seen in the '80s) are absolutely realistic. The novel is as relevant today as ever; feminist backlashes continue to wax and wane, but women's rights remain in the spotlight. And despite its scenarios of great despair, The Handmaid's Tale is ultimately a hopeful book - Offred, and others, simply cannot be human without the possibility of hope, and therein lies the strength of the resistance. All of Atwood is worth reading, but this book best exemplifies the cultural and psychological impact that a work of fiction can create.","84, 46669"
10,The Hitchhikers Guide to the Galaxy,Douglas Adams,"Parodying practically every well-worn sci-fi plot device in existence, Adams's Hitchhiker's Guide to the Galaxy has become a classic in its own right. A hapless hero with astonishing luck? Ill-tempered aliens hell-bent on destroying Earth? Pithy advice (e.g., ""DON'T PANIC"")? Check, check, and check - and so much more. Even non–sci-fi geeks will be charmed by this hilarious and endlessly entertaining read, with (of course) sequels following.","6, 19723"
11,In on a Winter's Night a Traveler,Italo Calvino,"For those with an amorous affair with books, If on a Winter's Night a Traveler may well be the ultimate love letter to the reader. Calvino's novel is a masterfully created, startlingly unique work of fiction. Told alternately in second- and third-person narratives, the book is a fascinating exploration of the relationship between the author and the reader - weaving together seemingly unrelated tales, all of which relate directly to you, the reader. At its core is an ingenious concept the likes of which could have only come from the unparalleled imagination of Calvino. By the time you reach its dazzling conclusion, you'll be wishing you could somehow read it again for the very first time.","72, 93697"
12,Infinite Jest,David Foster Wallace,"Infinite Jest is unique; it was bred in the optimism and new frontiersmanship of the dot-com 1990s but was simultaneously an early omen of where we are today. It looks into our present beyond what were only horizons when it was written: the tensions of a global economy, the opiate of on-demand entertainment, the near-impossible pursuit of greatness in a winner-take-all society. Tennis phenoms struggle in an absurdly demanding academy and recovering addicts search for something strong enough to help them through, all while a cadre of legless Quebecois assassins search for a movie so entertaining that they plan to use it as a weapon. At turns madcap and heart-wrenching, this is the tour-de-force novel of the forces that have shaped our new millennium and will likely continue shaping it for decades to come.","93, 66226"
13,The Left Hand of Darkness,Ursula K Le Guin,"Not only is The Left Hand of Darkness a masterpiece of ideas, invention, and language, but it takes conventional assumptions about gender and grinds them into a fine, powdery dust. Published in 1969, the book won both the Hugo and Nebula Awards and went on to become one of the keystones of science fiction. It tells the story of an ethnologist sent to another planet, but it is Le Guin's powers of imagination that turn The Left Hand of Darkness into something truly transcendent.","44, 11458"
14,Lolita,Vladimir Nabokov,"Why should everyone read a book about a pedophile's obsessive and frankly gross relationship with a little girl? Because if you are a reader - a lover of words, puns, witticisms, metaphors, and allusions - Lolita is a literary masterpiece that can't be passed over in a fit of queasy morality. Humbert Humbert, the novel's unreliable narrator, knows that he's a despicable pervert and yet the reader can't help enjoying him as he surveys post-war America and little Lolita with the droll, cynical eye of a European expat adrift in a tawdry nation, and stuck irrevocably - and irredeemably - in the memory of an adolescent love affair. Please, ignore the critics: Lolita isn't a morality tale and it isn't a love story. It's an unabashed look at a deviant mind written in some of the most deft and beautiful English ever published.","16, 91172"
15,Man's Search for Meaning,Viktor E Frankl,"Man's Search for Meaning is like nothing you've ever read before. The first half of the book depicts Dr. Frankl's four years losing everything in concentration camps - a description so hellish, it leaves you desolate. Shattered by his Holocaust experiences, Frankl struggles to survive after he is freed. In the second half of the book, Frankl shows how that period of his life informs and develops his theory of ""logotherapy"" - he asserts that life is about finding meaning, what is meaningful to each individual. As excruciating as his experiences are, Frankl's theory is full of love; he is able to find redemption for himself and others. This book is beautifully life-changing.","16, 23912"
16,Maus,Art Spiegelman,"The twofold brilliance of Art Spiegelman's groundbreaking, autobiographical Maus is the graphic novel's lack of sentimentality and Spiegelman's self-portrait as a secondhand Holocaust survivor. The Holocaust is a widely used trope in Jewish American writing and although Spiegelman treats the subject with the compassion and historical sensitivity it merits, Maus avoids the themes of victimization and historical exceptionalism that render much Holocaust literature precious and insulated from the present. Instead, Spiegelman gives his characters the dignity of fully fleshed, complicated personalities and shows - in sometimes painful and unappealing ways - how his parents' Holocaust seeped into his childhood and haunts his being.","97, 85306"
17,Never Let Me Go,Kazuo Ishiguro,"This is the kind of book that captures you so completely you find yourself reading it at work with the book covering your keyboard, hoping no one notices but also not really caring if you get fired. It's a subtle sci-fi story about youth, freedom, and a lot of other good stuff - too much more about the plot might take something away from the magical, transformative experience of reading it. Instead, I will say that the honest way Never Let Me Go deals with love and disappointment makes it a book that anyone who ever plans to love another person should probably read immediately. ","26, 13564"
18,A People's History of the United States,Howard Zinn,"While some of the revelations contained within this classic by Howard Zinn have become familiar since the nearly 35 years after it was published (thanks in part to this book), it is to this day an astonishing and eye-opening read. Several revisions later, it remains a seminal work, in stark contrast to the whitewashed (pun intended) American history most of us learned by rote in school. It's regretful with Zinn's passing in 2010 that new revisions have ceased for future generations to discover.","96, 17837"
19,The Phantom Tollbooth,Norton Juster,"The Phantom Tollbooth is the story of Milo, a very bored boy who comes home one day to find a magical tollbooth in his room. When Milo drives his car through the tollbooth gate, he finds himself in the Lands Beyond, a country inhabited by living language in the forms of animals, magicians, royalty, mountains, seas, and cities. From Tock the Watchdog to the listless region of The Doldrums, Milo shakes off boredom as he pursues the kidnapped Princesses Rhyme and Reason and restores peace to the Lands (currently in the clutches of the warring princes, Azaz of Dictionopolis and the Mathemagician of Digitopolis, along with a pack of demons). What sets The Phantom Tollbooth apart from other wonderful swashbuckling middle-readers is that it's also about the transformative power of language: open a book (or drive through a ""tollbooth"") and even the dreariest day dissolves into the din and glory of adventure.","20, 88130"
20,Poems,Elizabeth Bishop,"Elizabeth Bishop's poetry is dearly loved amongst her fans but perhaps not as well-known as it should be; for one of America's towering talents of the 20th century, she is not read nearly as much as Eliot or Whitman, or even cummings. That may be in part because of her relatively slim output - this volume of all her poetic works clocks in at only 368 pages. But the care she took with her poetry is evident; every word is perfectly chosen, none wasted or missing. Her work is fiercely intelligent, poignant, surprising, plainspoken, and wrought from imagery both familiar and extraordinary. A must-read for anyone who is interested in poetry, language, or indeed literature at all, Bishop's Poems speaks deeply to what makes us human. ","54, 23476"
21,Slaughterhouse-Five,Kurt Vonnegut,"What Kurt Vonnegut set out to do was write a book about war, and in particular the firebombing of Dresden in World War II. What he ended up doing was writing clean around it - traveling in and out of time warps, bouncing on and off the earth, sometimes setting down on the planet Tralfamadore, millions of miles away from Dresden and millions of miles away from war. What he created was a masterpiece of satire in which every crazy, clever moment, every whimsical line, no matter how deceptively light, is imbued with the sorrow and the starkness of the atrocity Vonnegut himself witnessed in that very real war.","88, 62848"
22,Things Fall Apart,Chinua Achebe,"Before Things Fall Apart was published in 1958, few novels existed in English that depicted African life from the African perspective. And while the book has paved the way for countless authors since, Chinua Achebe's illuminating work remains a classic of modern African literature. Drawing on the history and customs passed down to him, Achebe tells the tale Okonkwo, a strong-willed member of a late-19th-century Nigerian village. As we follow Okonkwo's story, we get a glimpse of the intricacies of village life and the complex social structures that come into play. We then see the devastating effects of European colonization on the region and on Okonkwo himself, whose rise and fall become intertwined with the changing power dynamics. Things Fall Apart is essential reading for anyone who wants a more nuanced understanding of other ways of life, of culture clashes, of what being civilized really entails.","16, 94548"
23,To Kill a Mockingbird,Harper Lee,"While To Kill a Mockingbird is a favorite book of pretty much everyone who has read it, it's important to remember that it continues to be subversive and challenging to the status quo. The protagonist is a young girl named Scout and except for her father, all the main characters in the book are marginalized by the power structure of their town - a structure that still exists nearly everywhere - where wealthy white men control the lives of everyone else, and even the members of that group who want to use their status for something honorable, like Scout's father Atticus, cannot win against the flattening wave of that power. Until something about that structure really changes, this book will remain required reading for every person in America.","1, 93991"
24,Where the Wild Things Are,Maurice Sendak,"We all hold our favorite childhood books dear, but there's a reason Where the Wild Things Are is one of the most beloved picture books of all time. Of course it's about Maurice Sendak's whimsy, his spare poetry, his imagination. Of course it's about his impeccably detailed illustrations, depicting the beauty of a night of wild rumpus and the elegant fiendishness of wild things who gnash their terrible teeth and roll their terrible eyes. But mostly I think it's because underneath the boundless (yet beautifully bounded) inventiveness of Sendak's world, we see - and remember - exactly what it is to be a child.","60, 64838"
25,The Wind-Up Bird Chronicle,Haruki Murakami,"Known for his beautiful, haunting, lyrical, and - at times - funny surrealistic stylings, Haruki Murakami is one of the most beloved Japanese authors in the Western world. Although infused with the pop culture of the West, his writing remains at its core firmly rooted in Japan. And as modern as his style is, his work draws upon the country's past while delving deep into the Japanese psyche. The Wind-Up Bird Chronicle is pure Murakami - a vast, enchanting mystery filled with dreamlike surrealism. Considered by many to be his best work, the novel tackles themes as varied as the nature of consciousness, romantic disappointment, and the lingering wounds of World War II. Readers will eagerly want to unravel this intricate, multi-layered tale.","56, 50224"
end{filecontents*}

usepackage{datatool}
setlength{parindent}{0pt} % Remove paragraph indentation

begin{document}

% Load CSV file
DTLloaddb
{file} % DB name
{file.csv} % filename

DTLforeach
{file} % DB name
{Title=Title,
Author=Author,
Summary=Summary,
Metadata=Metadata%
}% Assignment list
{%
section*{Title}
subsection*{by Author}

Summary: Summary

Metadata: Metadata

hrulefill
clearpage
}

end{document}




Let's assume file.csv contains the above list of titles, authors, summaries, ... Then you can clean any HTML code contained within the summaries using the following R script:



library(tidyverse)

# [Removing html tags from a string in R](https://stackoverflow.com/q/17227294/914686)
cleanFun <- function(htmlString) {
htmlString = gsub("&nbsp;", " ", htmlString)
htmlString = gsub("&gt;", "$>$", htmlString)
htmlString = gsub("&lt;", "$<$", htmlString)
htmlString = gsub("&amp;", "&", htmlString)
htmlString = gsub("&", "\\&", htmlString)
htmlString = gsub("@;", "\\@", htmlString)
htmlString = gsub("<i>", "\\textit{", htmlString)
htmlString = gsub("</i>", "}", htmlString)
htmlString = gsub("<b>", "\\textbf{", htmlString)
htmlString = gsub("</b>", "}", htmlString)
htmlString = gsub("<em>", "\\emph{", htmlString)
htmlString = gsub("</em>", "}", htmlString)
htmlString = gsub("<strong>", "\\textbf{", htmlString)
htmlString = gsub("</strong>", "}", htmlString)
htmlString = gsub("<u>", "\\underline{", htmlString)
htmlString = gsub("</u>", "}", htmlString)
htmlString = gsub("<a*?>", "\\underline{\\texttt{", htmlString)
htmlString = gsub("</a>", "}}", htmlString)
htmlString = gsub("<sup>", "\\textsuperscript{", htmlString)
htmlString = gsub("</sup>", "}", htmlString)
htmlString = gsub("<.*?>", "", htmlString)
return(htmlString)
}

input <- read_csv(
file = 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/file.csv'
)

input <- input %>% mutate(
CleanSummary = Summary %>% cleanFun()
)

output <- 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/output.tex'

# LaTeX document preamble
cat(
paste(
'\documentclass{article}',
'\usepackage[utf8]{inputenc}',
'\usepackage[T1]{fontenc}',
'\begin{document}',
sep = 'n' # line-break
),
file = output
)

# LaTeX document body
for (cur_item in 1:nrow(input)) {

cat(
paste0(
'nn\clearpage',
'nn\section{', input$Title[cur_item], '}',
'n\subsection{by ', input$Author[cur_item], '}',
'nSummary: ', input$CleanSummary[cur_item],
'n', # line-break
'nMetadata: ', input$Metadata[cur_item]
),
file = output,
append = TRUE
)

}

# LaTeX document end
cat(
'nn\end{document}',
file = output,
append = TRUE
)


It produces, as output.tex a file that you can compile using LaTeX without having to process it entirely using datatool:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
begin{document}

clearpage

section{2666}
subsection{by Roberto Bolano}
Summary: Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the "total novel," 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.

Metadata: 7, 98213

clearpage

section{All About Love}
subsection{by Bell Hooks}
Summary: We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.

Metadata: 1, 75014

clearpage

[...]

end{document}





share|improve this answer























  • Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
    – user3445853
    Nov 20 at 22:59










  • Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
    – user3445853
    Nov 20 at 23:04










  • @user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
    – Werner
    Nov 21 at 1:50










  • sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
    – user3445853
    Nov 21 at 11:56










  • [Previous was @werner but comment can onyl be edited for 5min.]
    – user3445853
    Nov 21 at 14:14











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379670%2freasonable-tool-to-convert-a-spreadsheet-to-text-with-one-row-one-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










The following LaTeX code takes a CSV as input and outputs a single page per row based on the content within the input file.



enter image description here



documentclass{article}

usepackage{filecontents}
% https://www.powells.com/25-books-to-read-before-you-die
begin{filecontents*}{file.csv}
Number,Title,Author,Summary,Metadata
1,2666,Roberto Bolano,"Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the ""total novel,"" 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.","7, 98213"
2,All About Love,Bell Hooks,"We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.","1, 75014"
3,Desert Solitaire,Edward Abbey,"No author encapsulated and celebrated the American Southwest more engagingly than iconoclast and raconteur Edward Abbey. Desert Solitaire: A Season in the Wilderness - now nearly a half-century old - is a classic of environmental writing. In this autobiographical work, Abbey chronicles his time as a park ranger and reflects on landscape, culture, politics, tourism, environmental disregard, and degradation - doing so with a unique blend of ornery charm and breathtaking description. Though set in his beloved Southwest, Desert Solitaire beautifully and brashly captures the essence of the American outdoors, replete with disdain for those who'd seek to spoil its natural wonder.","10, 57475"
4,Disgrace,JM Coetzee,"One afternoon while talking with a friend about books, I wondered how to best describe my experience of reading Disgrace, and this is what I came up with: it's like a finely crafted, very sharp knife resting gently against your skin. The uneasiness and suspense are there from the beginning, made all the more powerful by Coetzee's control and use of spare language, and you never really take a deep breath until it's all over. Set in modern South Africa, the book explores what it's like to personally confront deep prejudices. Prejudices of gender, sexuality, class, and race. Far from being a politically correct diatribe, this novel is about how we cope, how we survive as humans, and it forces the reader to reflect upon what seems at first a very twisted reality. For each of the characters in this astonishing novel, redemption is attained through what becomes the very reshaping of their souls.","4, 3245"
5,Geek Love,Katherine Dunn,"This is the book I recommend more than any other - I can barely hold onto a copy of it because I am always giving it away to anyone who I think needs something that will blow the top of their skull off. On one level, it is the engaging, creepy, and extraordinary story of a family of purposely designed circus freaks, as told by the hunchback albino dwarf sister. On another level, it is a story about identity and belonging: How do you define yourself in terms of your family? Your culture? Your body? Your religion? How do you know what or who you really are?","74, 87170"
6,Gilead,Marilynne Robinson,"Set in 1956, Marilynne Robinson's Gilead is a letter from the elderly Reverend John Ames to his very young son. Ames has lived all of his life in Gilead, Iowa, and the novel delves into the history of the area through the characters of Ames's father and grandfather - also ministers, but deeply divided on ideas such as pacifism, duty, and the abolitionist movement. And eventually, when John Ames Boughton, Ames's namesake and godson, returns to Gilead, he brings up old tensions and sets events in motion that disturb Ames's formerly peaceful last days. Gilead is one of the most beautifully written books of the new century thus far, and Robinson's incredibly insightful grappling with faith, mortality, and what constitutes a meaningful life will resonate with readers across every spectrum.","88, 81905"
7,Giovanni's Room,James Baldwin,"It would be difficult to talk about James Baldwin's Giovanni's Room and not touch on the simple fact that this slim novel, published in 1956, is mainly a love story between two men. It seems impossible to think such a thing could be published pre-Stonewall, but such is the genius of Baldwin and the way he captures the complexities of desire, love, and the tragic cost that comes from not following your heart. ""Somebody…should have told us that not many people have ever died of love. But multitudes have perished…for the lack of it."" This emotional wonder of a book comes down to two things: love and death. And really, what else is there in life?","6, 53009"
8,A Good Man Is Hard To Find and Other Stories,Flannery O'Connor,"Flannery O'Connor's first short story collection, written in 1955, will knock you off your feet. Ruthless, penetrating, and loaded with subtext, A Good Man Is Hard to Find and Other Stories was brave for its time and feels just as consequential today. Writing in the Southern Gothic tradition in a style wholly her own, O'Connor creates characters that are misguided, stunted curiosities, but she manages to capture what's human in even the most despicable of people - which makes their doomed trajectories feel all the more tragic. And despite the disturbing events that unfold, the stories are a pleasure to read - they're infused with suspense, dark humor, and some of the most evocative imagery you'll encounter in literature. All this makes for a collection that never ceases to amaze - and begs to be reread.","40, 73776"
9,The Handmaid's Tale,Margaret Atwood,"Atwood's classic dystopian novel of a terrifying (and terrifyingly plausible) future America has rewarded rereading like no other book; I've probably read it 30 times by now. The world of the narrator, Offred (from ""Of Fred"" - women no longer have their own names), is chilling, but she is a magnificent survivor and chronicler, and the details of everything from mundane daily life to ritualized sex and violence to her reminiscences of the time before (our contemporary reality, as seen in the '80s) are absolutely realistic. The novel is as relevant today as ever; feminist backlashes continue to wax and wane, but women's rights remain in the spotlight. And despite its scenarios of great despair, The Handmaid's Tale is ultimately a hopeful book - Offred, and others, simply cannot be human without the possibility of hope, and therein lies the strength of the resistance. All of Atwood is worth reading, but this book best exemplifies the cultural and psychological impact that a work of fiction can create.","84, 46669"
10,The Hitchhikers Guide to the Galaxy,Douglas Adams,"Parodying practically every well-worn sci-fi plot device in existence, Adams's Hitchhiker's Guide to the Galaxy has become a classic in its own right. A hapless hero with astonishing luck? Ill-tempered aliens hell-bent on destroying Earth? Pithy advice (e.g., ""DON'T PANIC"")? Check, check, and check - and so much more. Even non–sci-fi geeks will be charmed by this hilarious and endlessly entertaining read, with (of course) sequels following.","6, 19723"
11,In on a Winter's Night a Traveler,Italo Calvino,"For those with an amorous affair with books, If on a Winter's Night a Traveler may well be the ultimate love letter to the reader. Calvino's novel is a masterfully created, startlingly unique work of fiction. Told alternately in second- and third-person narratives, the book is a fascinating exploration of the relationship between the author and the reader - weaving together seemingly unrelated tales, all of which relate directly to you, the reader. At its core is an ingenious concept the likes of which could have only come from the unparalleled imagination of Calvino. By the time you reach its dazzling conclusion, you'll be wishing you could somehow read it again for the very first time.","72, 93697"
12,Infinite Jest,David Foster Wallace,"Infinite Jest is unique; it was bred in the optimism and new frontiersmanship of the dot-com 1990s but was simultaneously an early omen of where we are today. It looks into our present beyond what were only horizons when it was written: the tensions of a global economy, the opiate of on-demand entertainment, the near-impossible pursuit of greatness in a winner-take-all society. Tennis phenoms struggle in an absurdly demanding academy and recovering addicts search for something strong enough to help them through, all while a cadre of legless Quebecois assassins search for a movie so entertaining that they plan to use it as a weapon. At turns madcap and heart-wrenching, this is the tour-de-force novel of the forces that have shaped our new millennium and will likely continue shaping it for decades to come.","93, 66226"
13,The Left Hand of Darkness,Ursula K Le Guin,"Not only is The Left Hand of Darkness a masterpiece of ideas, invention, and language, but it takes conventional assumptions about gender and grinds them into a fine, powdery dust. Published in 1969, the book won both the Hugo and Nebula Awards and went on to become one of the keystones of science fiction. It tells the story of an ethnologist sent to another planet, but it is Le Guin's powers of imagination that turn The Left Hand of Darkness into something truly transcendent.","44, 11458"
14,Lolita,Vladimir Nabokov,"Why should everyone read a book about a pedophile's obsessive and frankly gross relationship with a little girl? Because if you are a reader - a lover of words, puns, witticisms, metaphors, and allusions - Lolita is a literary masterpiece that can't be passed over in a fit of queasy morality. Humbert Humbert, the novel's unreliable narrator, knows that he's a despicable pervert and yet the reader can't help enjoying him as he surveys post-war America and little Lolita with the droll, cynical eye of a European expat adrift in a tawdry nation, and stuck irrevocably - and irredeemably - in the memory of an adolescent love affair. Please, ignore the critics: Lolita isn't a morality tale and it isn't a love story. It's an unabashed look at a deviant mind written in some of the most deft and beautiful English ever published.","16, 91172"
15,Man's Search for Meaning,Viktor E Frankl,"Man's Search for Meaning is like nothing you've ever read before. The first half of the book depicts Dr. Frankl's four years losing everything in concentration camps - a description so hellish, it leaves you desolate. Shattered by his Holocaust experiences, Frankl struggles to survive after he is freed. In the second half of the book, Frankl shows how that period of his life informs and develops his theory of ""logotherapy"" - he asserts that life is about finding meaning, what is meaningful to each individual. As excruciating as his experiences are, Frankl's theory is full of love; he is able to find redemption for himself and others. This book is beautifully life-changing.","16, 23912"
16,Maus,Art Spiegelman,"The twofold brilliance of Art Spiegelman's groundbreaking, autobiographical Maus is the graphic novel's lack of sentimentality and Spiegelman's self-portrait as a secondhand Holocaust survivor. The Holocaust is a widely used trope in Jewish American writing and although Spiegelman treats the subject with the compassion and historical sensitivity it merits, Maus avoids the themes of victimization and historical exceptionalism that render much Holocaust literature precious and insulated from the present. Instead, Spiegelman gives his characters the dignity of fully fleshed, complicated personalities and shows - in sometimes painful and unappealing ways - how his parents' Holocaust seeped into his childhood and haunts his being.","97, 85306"
17,Never Let Me Go,Kazuo Ishiguro,"This is the kind of book that captures you so completely you find yourself reading it at work with the book covering your keyboard, hoping no one notices but also not really caring if you get fired. It's a subtle sci-fi story about youth, freedom, and a lot of other good stuff - too much more about the plot might take something away from the magical, transformative experience of reading it. Instead, I will say that the honest way Never Let Me Go deals with love and disappointment makes it a book that anyone who ever plans to love another person should probably read immediately. ","26, 13564"
18,A People's History of the United States,Howard Zinn,"While some of the revelations contained within this classic by Howard Zinn have become familiar since the nearly 35 years after it was published (thanks in part to this book), it is to this day an astonishing and eye-opening read. Several revisions later, it remains a seminal work, in stark contrast to the whitewashed (pun intended) American history most of us learned by rote in school. It's regretful with Zinn's passing in 2010 that new revisions have ceased for future generations to discover.","96, 17837"
19,The Phantom Tollbooth,Norton Juster,"The Phantom Tollbooth is the story of Milo, a very bored boy who comes home one day to find a magical tollbooth in his room. When Milo drives his car through the tollbooth gate, he finds himself in the Lands Beyond, a country inhabited by living language in the forms of animals, magicians, royalty, mountains, seas, and cities. From Tock the Watchdog to the listless region of The Doldrums, Milo shakes off boredom as he pursues the kidnapped Princesses Rhyme and Reason and restores peace to the Lands (currently in the clutches of the warring princes, Azaz of Dictionopolis and the Mathemagician of Digitopolis, along with a pack of demons). What sets The Phantom Tollbooth apart from other wonderful swashbuckling middle-readers is that it's also about the transformative power of language: open a book (or drive through a ""tollbooth"") and even the dreariest day dissolves into the din and glory of adventure.","20, 88130"
20,Poems,Elizabeth Bishop,"Elizabeth Bishop's poetry is dearly loved amongst her fans but perhaps not as well-known as it should be; for one of America's towering talents of the 20th century, she is not read nearly as much as Eliot or Whitman, or even cummings. That may be in part because of her relatively slim output - this volume of all her poetic works clocks in at only 368 pages. But the care she took with her poetry is evident; every word is perfectly chosen, none wasted or missing. Her work is fiercely intelligent, poignant, surprising, plainspoken, and wrought from imagery both familiar and extraordinary. A must-read for anyone who is interested in poetry, language, or indeed literature at all, Bishop's Poems speaks deeply to what makes us human. ","54, 23476"
21,Slaughterhouse-Five,Kurt Vonnegut,"What Kurt Vonnegut set out to do was write a book about war, and in particular the firebombing of Dresden in World War II. What he ended up doing was writing clean around it - traveling in and out of time warps, bouncing on and off the earth, sometimes setting down on the planet Tralfamadore, millions of miles away from Dresden and millions of miles away from war. What he created was a masterpiece of satire in which every crazy, clever moment, every whimsical line, no matter how deceptively light, is imbued with the sorrow and the starkness of the atrocity Vonnegut himself witnessed in that very real war.","88, 62848"
22,Things Fall Apart,Chinua Achebe,"Before Things Fall Apart was published in 1958, few novels existed in English that depicted African life from the African perspective. And while the book has paved the way for countless authors since, Chinua Achebe's illuminating work remains a classic of modern African literature. Drawing on the history and customs passed down to him, Achebe tells the tale Okonkwo, a strong-willed member of a late-19th-century Nigerian village. As we follow Okonkwo's story, we get a glimpse of the intricacies of village life and the complex social structures that come into play. We then see the devastating effects of European colonization on the region and on Okonkwo himself, whose rise and fall become intertwined with the changing power dynamics. Things Fall Apart is essential reading for anyone who wants a more nuanced understanding of other ways of life, of culture clashes, of what being civilized really entails.","16, 94548"
23,To Kill a Mockingbird,Harper Lee,"While To Kill a Mockingbird is a favorite book of pretty much everyone who has read it, it's important to remember that it continues to be subversive and challenging to the status quo. The protagonist is a young girl named Scout and except for her father, all the main characters in the book are marginalized by the power structure of their town - a structure that still exists nearly everywhere - where wealthy white men control the lives of everyone else, and even the members of that group who want to use their status for something honorable, like Scout's father Atticus, cannot win against the flattening wave of that power. Until something about that structure really changes, this book will remain required reading for every person in America.","1, 93991"
24,Where the Wild Things Are,Maurice Sendak,"We all hold our favorite childhood books dear, but there's a reason Where the Wild Things Are is one of the most beloved picture books of all time. Of course it's about Maurice Sendak's whimsy, his spare poetry, his imagination. Of course it's about his impeccably detailed illustrations, depicting the beauty of a night of wild rumpus and the elegant fiendishness of wild things who gnash their terrible teeth and roll their terrible eyes. But mostly I think it's because underneath the boundless (yet beautifully bounded) inventiveness of Sendak's world, we see - and remember - exactly what it is to be a child.","60, 64838"
25,The Wind-Up Bird Chronicle,Haruki Murakami,"Known for his beautiful, haunting, lyrical, and - at times - funny surrealistic stylings, Haruki Murakami is one of the most beloved Japanese authors in the Western world. Although infused with the pop culture of the West, his writing remains at its core firmly rooted in Japan. And as modern as his style is, his work draws upon the country's past while delving deep into the Japanese psyche. The Wind-Up Bird Chronicle is pure Murakami - a vast, enchanting mystery filled with dreamlike surrealism. Considered by many to be his best work, the novel tackles themes as varied as the nature of consciousness, romantic disappointment, and the lingering wounds of World War II. Readers will eagerly want to unravel this intricate, multi-layered tale.","56, 50224"
end{filecontents*}

usepackage{datatool}
setlength{parindent}{0pt} % Remove paragraph indentation

begin{document}

% Load CSV file
DTLloaddb
{file} % DB name
{file.csv} % filename

DTLforeach
{file} % DB name
{Title=Title,
Author=Author,
Summary=Summary,
Metadata=Metadata%
}% Assignment list
{%
section*{Title}
subsection*{by Author}

Summary: Summary

Metadata: Metadata

hrulefill
clearpage
}

end{document}




Let's assume file.csv contains the above list of titles, authors, summaries, ... Then you can clean any HTML code contained within the summaries using the following R script:



library(tidyverse)

# [Removing html tags from a string in R](https://stackoverflow.com/q/17227294/914686)
cleanFun <- function(htmlString) {
htmlString = gsub("&nbsp;", " ", htmlString)
htmlString = gsub("&gt;", "$>$", htmlString)
htmlString = gsub("&lt;", "$<$", htmlString)
htmlString = gsub("&amp;", "&", htmlString)
htmlString = gsub("&", "\\&", htmlString)
htmlString = gsub("@;", "\\@", htmlString)
htmlString = gsub("<i>", "\\textit{", htmlString)
htmlString = gsub("</i>", "}", htmlString)
htmlString = gsub("<b>", "\\textbf{", htmlString)
htmlString = gsub("</b>", "}", htmlString)
htmlString = gsub("<em>", "\\emph{", htmlString)
htmlString = gsub("</em>", "}", htmlString)
htmlString = gsub("<strong>", "\\textbf{", htmlString)
htmlString = gsub("</strong>", "}", htmlString)
htmlString = gsub("<u>", "\\underline{", htmlString)
htmlString = gsub("</u>", "}", htmlString)
htmlString = gsub("<a*?>", "\\underline{\\texttt{", htmlString)
htmlString = gsub("</a>", "}}", htmlString)
htmlString = gsub("<sup>", "\\textsuperscript{", htmlString)
htmlString = gsub("</sup>", "}", htmlString)
htmlString = gsub("<.*?>", "", htmlString)
return(htmlString)
}

input <- read_csv(
file = 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/file.csv'
)

input <- input %>% mutate(
CleanSummary = Summary %>% cleanFun()
)

output <- 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/output.tex'

# LaTeX document preamble
cat(
paste(
'\documentclass{article}',
'\usepackage[utf8]{inputenc}',
'\usepackage[T1]{fontenc}',
'\begin{document}',
sep = 'n' # line-break
),
file = output
)

# LaTeX document body
for (cur_item in 1:nrow(input)) {

cat(
paste0(
'nn\clearpage',
'nn\section{', input$Title[cur_item], '}',
'n\subsection{by ', input$Author[cur_item], '}',
'nSummary: ', input$CleanSummary[cur_item],
'n', # line-break
'nMetadata: ', input$Metadata[cur_item]
),
file = output,
append = TRUE
)

}

# LaTeX document end
cat(
'nn\end{document}',
file = output,
append = TRUE
)


It produces, as output.tex a file that you can compile using LaTeX without having to process it entirely using datatool:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
begin{document}

clearpage

section{2666}
subsection{by Roberto Bolano}
Summary: Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the "total novel," 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.

Metadata: 7, 98213

clearpage

section{All About Love}
subsection{by Bell Hooks}
Summary: We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.

Metadata: 1, 75014

clearpage

[...]

end{document}





share|improve this answer























  • Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
    – user3445853
    Nov 20 at 22:59










  • Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
    – user3445853
    Nov 20 at 23:04










  • @user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
    – Werner
    Nov 21 at 1:50










  • sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
    – user3445853
    Nov 21 at 11:56










  • [Previous was @werner but comment can onyl be edited for 5min.]
    – user3445853
    Nov 21 at 14:14















up vote
0
down vote



accepted










The following LaTeX code takes a CSV as input and outputs a single page per row based on the content within the input file.



enter image description here



documentclass{article}

usepackage{filecontents}
% https://www.powells.com/25-books-to-read-before-you-die
begin{filecontents*}{file.csv}
Number,Title,Author,Summary,Metadata
1,2666,Roberto Bolano,"Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the ""total novel,"" 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.","7, 98213"
2,All About Love,Bell Hooks,"We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.","1, 75014"
3,Desert Solitaire,Edward Abbey,"No author encapsulated and celebrated the American Southwest more engagingly than iconoclast and raconteur Edward Abbey. Desert Solitaire: A Season in the Wilderness - now nearly a half-century old - is a classic of environmental writing. In this autobiographical work, Abbey chronicles his time as a park ranger and reflects on landscape, culture, politics, tourism, environmental disregard, and degradation - doing so with a unique blend of ornery charm and breathtaking description. Though set in his beloved Southwest, Desert Solitaire beautifully and brashly captures the essence of the American outdoors, replete with disdain for those who'd seek to spoil its natural wonder.","10, 57475"
4,Disgrace,JM Coetzee,"One afternoon while talking with a friend about books, I wondered how to best describe my experience of reading Disgrace, and this is what I came up with: it's like a finely crafted, very sharp knife resting gently against your skin. The uneasiness and suspense are there from the beginning, made all the more powerful by Coetzee's control and use of spare language, and you never really take a deep breath until it's all over. Set in modern South Africa, the book explores what it's like to personally confront deep prejudices. Prejudices of gender, sexuality, class, and race. Far from being a politically correct diatribe, this novel is about how we cope, how we survive as humans, and it forces the reader to reflect upon what seems at first a very twisted reality. For each of the characters in this astonishing novel, redemption is attained through what becomes the very reshaping of their souls.","4, 3245"
5,Geek Love,Katherine Dunn,"This is the book I recommend more than any other - I can barely hold onto a copy of it because I am always giving it away to anyone who I think needs something that will blow the top of their skull off. On one level, it is the engaging, creepy, and extraordinary story of a family of purposely designed circus freaks, as told by the hunchback albino dwarf sister. On another level, it is a story about identity and belonging: How do you define yourself in terms of your family? Your culture? Your body? Your religion? How do you know what or who you really are?","74, 87170"
6,Gilead,Marilynne Robinson,"Set in 1956, Marilynne Robinson's Gilead is a letter from the elderly Reverend John Ames to his very young son. Ames has lived all of his life in Gilead, Iowa, and the novel delves into the history of the area through the characters of Ames's father and grandfather - also ministers, but deeply divided on ideas such as pacifism, duty, and the abolitionist movement. And eventually, when John Ames Boughton, Ames's namesake and godson, returns to Gilead, he brings up old tensions and sets events in motion that disturb Ames's formerly peaceful last days. Gilead is one of the most beautifully written books of the new century thus far, and Robinson's incredibly insightful grappling with faith, mortality, and what constitutes a meaningful life will resonate with readers across every spectrum.","88, 81905"
7,Giovanni's Room,James Baldwin,"It would be difficult to talk about James Baldwin's Giovanni's Room and not touch on the simple fact that this slim novel, published in 1956, is mainly a love story between two men. It seems impossible to think such a thing could be published pre-Stonewall, but such is the genius of Baldwin and the way he captures the complexities of desire, love, and the tragic cost that comes from not following your heart. ""Somebody…should have told us that not many people have ever died of love. But multitudes have perished…for the lack of it."" This emotional wonder of a book comes down to two things: love and death. And really, what else is there in life?","6, 53009"
8,A Good Man Is Hard To Find and Other Stories,Flannery O'Connor,"Flannery O'Connor's first short story collection, written in 1955, will knock you off your feet. Ruthless, penetrating, and loaded with subtext, A Good Man Is Hard to Find and Other Stories was brave for its time and feels just as consequential today. Writing in the Southern Gothic tradition in a style wholly her own, O'Connor creates characters that are misguided, stunted curiosities, but she manages to capture what's human in even the most despicable of people - which makes their doomed trajectories feel all the more tragic. And despite the disturbing events that unfold, the stories are a pleasure to read - they're infused with suspense, dark humor, and some of the most evocative imagery you'll encounter in literature. All this makes for a collection that never ceases to amaze - and begs to be reread.","40, 73776"
9,The Handmaid's Tale,Margaret Atwood,"Atwood's classic dystopian novel of a terrifying (and terrifyingly plausible) future America has rewarded rereading like no other book; I've probably read it 30 times by now. The world of the narrator, Offred (from ""Of Fred"" - women no longer have their own names), is chilling, but she is a magnificent survivor and chronicler, and the details of everything from mundane daily life to ritualized sex and violence to her reminiscences of the time before (our contemporary reality, as seen in the '80s) are absolutely realistic. The novel is as relevant today as ever; feminist backlashes continue to wax and wane, but women's rights remain in the spotlight. And despite its scenarios of great despair, The Handmaid's Tale is ultimately a hopeful book - Offred, and others, simply cannot be human without the possibility of hope, and therein lies the strength of the resistance. All of Atwood is worth reading, but this book best exemplifies the cultural and psychological impact that a work of fiction can create.","84, 46669"
10,The Hitchhikers Guide to the Galaxy,Douglas Adams,"Parodying practically every well-worn sci-fi plot device in existence, Adams's Hitchhiker's Guide to the Galaxy has become a classic in its own right. A hapless hero with astonishing luck? Ill-tempered aliens hell-bent on destroying Earth? Pithy advice (e.g., ""DON'T PANIC"")? Check, check, and check - and so much more. Even non–sci-fi geeks will be charmed by this hilarious and endlessly entertaining read, with (of course) sequels following.","6, 19723"
11,In on a Winter's Night a Traveler,Italo Calvino,"For those with an amorous affair with books, If on a Winter's Night a Traveler may well be the ultimate love letter to the reader. Calvino's novel is a masterfully created, startlingly unique work of fiction. Told alternately in second- and third-person narratives, the book is a fascinating exploration of the relationship between the author and the reader - weaving together seemingly unrelated tales, all of which relate directly to you, the reader. At its core is an ingenious concept the likes of which could have only come from the unparalleled imagination of Calvino. By the time you reach its dazzling conclusion, you'll be wishing you could somehow read it again for the very first time.","72, 93697"
12,Infinite Jest,David Foster Wallace,"Infinite Jest is unique; it was bred in the optimism and new frontiersmanship of the dot-com 1990s but was simultaneously an early omen of where we are today. It looks into our present beyond what were only horizons when it was written: the tensions of a global economy, the opiate of on-demand entertainment, the near-impossible pursuit of greatness in a winner-take-all society. Tennis phenoms struggle in an absurdly demanding academy and recovering addicts search for something strong enough to help them through, all while a cadre of legless Quebecois assassins search for a movie so entertaining that they plan to use it as a weapon. At turns madcap and heart-wrenching, this is the tour-de-force novel of the forces that have shaped our new millennium and will likely continue shaping it for decades to come.","93, 66226"
13,The Left Hand of Darkness,Ursula K Le Guin,"Not only is The Left Hand of Darkness a masterpiece of ideas, invention, and language, but it takes conventional assumptions about gender and grinds them into a fine, powdery dust. Published in 1969, the book won both the Hugo and Nebula Awards and went on to become one of the keystones of science fiction. It tells the story of an ethnologist sent to another planet, but it is Le Guin's powers of imagination that turn The Left Hand of Darkness into something truly transcendent.","44, 11458"
14,Lolita,Vladimir Nabokov,"Why should everyone read a book about a pedophile's obsessive and frankly gross relationship with a little girl? Because if you are a reader - a lover of words, puns, witticisms, metaphors, and allusions - Lolita is a literary masterpiece that can't be passed over in a fit of queasy morality. Humbert Humbert, the novel's unreliable narrator, knows that he's a despicable pervert and yet the reader can't help enjoying him as he surveys post-war America and little Lolita with the droll, cynical eye of a European expat adrift in a tawdry nation, and stuck irrevocably - and irredeemably - in the memory of an adolescent love affair. Please, ignore the critics: Lolita isn't a morality tale and it isn't a love story. It's an unabashed look at a deviant mind written in some of the most deft and beautiful English ever published.","16, 91172"
15,Man's Search for Meaning,Viktor E Frankl,"Man's Search for Meaning is like nothing you've ever read before. The first half of the book depicts Dr. Frankl's four years losing everything in concentration camps - a description so hellish, it leaves you desolate. Shattered by his Holocaust experiences, Frankl struggles to survive after he is freed. In the second half of the book, Frankl shows how that period of his life informs and develops his theory of ""logotherapy"" - he asserts that life is about finding meaning, what is meaningful to each individual. As excruciating as his experiences are, Frankl's theory is full of love; he is able to find redemption for himself and others. This book is beautifully life-changing.","16, 23912"
16,Maus,Art Spiegelman,"The twofold brilliance of Art Spiegelman's groundbreaking, autobiographical Maus is the graphic novel's lack of sentimentality and Spiegelman's self-portrait as a secondhand Holocaust survivor. The Holocaust is a widely used trope in Jewish American writing and although Spiegelman treats the subject with the compassion and historical sensitivity it merits, Maus avoids the themes of victimization and historical exceptionalism that render much Holocaust literature precious and insulated from the present. Instead, Spiegelman gives his characters the dignity of fully fleshed, complicated personalities and shows - in sometimes painful and unappealing ways - how his parents' Holocaust seeped into his childhood and haunts his being.","97, 85306"
17,Never Let Me Go,Kazuo Ishiguro,"This is the kind of book that captures you so completely you find yourself reading it at work with the book covering your keyboard, hoping no one notices but also not really caring if you get fired. It's a subtle sci-fi story about youth, freedom, and a lot of other good stuff - too much more about the plot might take something away from the magical, transformative experience of reading it. Instead, I will say that the honest way Never Let Me Go deals with love and disappointment makes it a book that anyone who ever plans to love another person should probably read immediately. ","26, 13564"
18,A People's History of the United States,Howard Zinn,"While some of the revelations contained within this classic by Howard Zinn have become familiar since the nearly 35 years after it was published (thanks in part to this book), it is to this day an astonishing and eye-opening read. Several revisions later, it remains a seminal work, in stark contrast to the whitewashed (pun intended) American history most of us learned by rote in school. It's regretful with Zinn's passing in 2010 that new revisions have ceased for future generations to discover.","96, 17837"
19,The Phantom Tollbooth,Norton Juster,"The Phantom Tollbooth is the story of Milo, a very bored boy who comes home one day to find a magical tollbooth in his room. When Milo drives his car through the tollbooth gate, he finds himself in the Lands Beyond, a country inhabited by living language in the forms of animals, magicians, royalty, mountains, seas, and cities. From Tock the Watchdog to the listless region of The Doldrums, Milo shakes off boredom as he pursues the kidnapped Princesses Rhyme and Reason and restores peace to the Lands (currently in the clutches of the warring princes, Azaz of Dictionopolis and the Mathemagician of Digitopolis, along with a pack of demons). What sets The Phantom Tollbooth apart from other wonderful swashbuckling middle-readers is that it's also about the transformative power of language: open a book (or drive through a ""tollbooth"") and even the dreariest day dissolves into the din and glory of adventure.","20, 88130"
20,Poems,Elizabeth Bishop,"Elizabeth Bishop's poetry is dearly loved amongst her fans but perhaps not as well-known as it should be; for one of America's towering talents of the 20th century, she is not read nearly as much as Eliot or Whitman, or even cummings. That may be in part because of her relatively slim output - this volume of all her poetic works clocks in at only 368 pages. But the care she took with her poetry is evident; every word is perfectly chosen, none wasted or missing. Her work is fiercely intelligent, poignant, surprising, plainspoken, and wrought from imagery both familiar and extraordinary. A must-read for anyone who is interested in poetry, language, or indeed literature at all, Bishop's Poems speaks deeply to what makes us human. ","54, 23476"
21,Slaughterhouse-Five,Kurt Vonnegut,"What Kurt Vonnegut set out to do was write a book about war, and in particular the firebombing of Dresden in World War II. What he ended up doing was writing clean around it - traveling in and out of time warps, bouncing on and off the earth, sometimes setting down on the planet Tralfamadore, millions of miles away from Dresden and millions of miles away from war. What he created was a masterpiece of satire in which every crazy, clever moment, every whimsical line, no matter how deceptively light, is imbued with the sorrow and the starkness of the atrocity Vonnegut himself witnessed in that very real war.","88, 62848"
22,Things Fall Apart,Chinua Achebe,"Before Things Fall Apart was published in 1958, few novels existed in English that depicted African life from the African perspective. And while the book has paved the way for countless authors since, Chinua Achebe's illuminating work remains a classic of modern African literature. Drawing on the history and customs passed down to him, Achebe tells the tale Okonkwo, a strong-willed member of a late-19th-century Nigerian village. As we follow Okonkwo's story, we get a glimpse of the intricacies of village life and the complex social structures that come into play. We then see the devastating effects of European colonization on the region and on Okonkwo himself, whose rise and fall become intertwined with the changing power dynamics. Things Fall Apart is essential reading for anyone who wants a more nuanced understanding of other ways of life, of culture clashes, of what being civilized really entails.","16, 94548"
23,To Kill a Mockingbird,Harper Lee,"While To Kill a Mockingbird is a favorite book of pretty much everyone who has read it, it's important to remember that it continues to be subversive and challenging to the status quo. The protagonist is a young girl named Scout and except for her father, all the main characters in the book are marginalized by the power structure of their town - a structure that still exists nearly everywhere - where wealthy white men control the lives of everyone else, and even the members of that group who want to use their status for something honorable, like Scout's father Atticus, cannot win against the flattening wave of that power. Until something about that structure really changes, this book will remain required reading for every person in America.","1, 93991"
24,Where the Wild Things Are,Maurice Sendak,"We all hold our favorite childhood books dear, but there's a reason Where the Wild Things Are is one of the most beloved picture books of all time. Of course it's about Maurice Sendak's whimsy, his spare poetry, his imagination. Of course it's about his impeccably detailed illustrations, depicting the beauty of a night of wild rumpus and the elegant fiendishness of wild things who gnash their terrible teeth and roll their terrible eyes. But mostly I think it's because underneath the boundless (yet beautifully bounded) inventiveness of Sendak's world, we see - and remember - exactly what it is to be a child.","60, 64838"
25,The Wind-Up Bird Chronicle,Haruki Murakami,"Known for his beautiful, haunting, lyrical, and - at times - funny surrealistic stylings, Haruki Murakami is one of the most beloved Japanese authors in the Western world. Although infused with the pop culture of the West, his writing remains at its core firmly rooted in Japan. And as modern as his style is, his work draws upon the country's past while delving deep into the Japanese psyche. The Wind-Up Bird Chronicle is pure Murakami - a vast, enchanting mystery filled with dreamlike surrealism. Considered by many to be his best work, the novel tackles themes as varied as the nature of consciousness, romantic disappointment, and the lingering wounds of World War II. Readers will eagerly want to unravel this intricate, multi-layered tale.","56, 50224"
end{filecontents*}

usepackage{datatool}
setlength{parindent}{0pt} % Remove paragraph indentation

begin{document}

% Load CSV file
DTLloaddb
{file} % DB name
{file.csv} % filename

DTLforeach
{file} % DB name
{Title=Title,
Author=Author,
Summary=Summary,
Metadata=Metadata%
}% Assignment list
{%
section*{Title}
subsection*{by Author}

Summary: Summary

Metadata: Metadata

hrulefill
clearpage
}

end{document}




Let's assume file.csv contains the above list of titles, authors, summaries, ... Then you can clean any HTML code contained within the summaries using the following R script:



library(tidyverse)

# [Removing html tags from a string in R](https://stackoverflow.com/q/17227294/914686)
cleanFun <- function(htmlString) {
htmlString = gsub("&nbsp;", " ", htmlString)
htmlString = gsub("&gt;", "$>$", htmlString)
htmlString = gsub("&lt;", "$<$", htmlString)
htmlString = gsub("&amp;", "&", htmlString)
htmlString = gsub("&", "\\&", htmlString)
htmlString = gsub("@;", "\\@", htmlString)
htmlString = gsub("<i>", "\\textit{", htmlString)
htmlString = gsub("</i>", "}", htmlString)
htmlString = gsub("<b>", "\\textbf{", htmlString)
htmlString = gsub("</b>", "}", htmlString)
htmlString = gsub("<em>", "\\emph{", htmlString)
htmlString = gsub("</em>", "}", htmlString)
htmlString = gsub("<strong>", "\\textbf{", htmlString)
htmlString = gsub("</strong>", "}", htmlString)
htmlString = gsub("<u>", "\\underline{", htmlString)
htmlString = gsub("</u>", "}", htmlString)
htmlString = gsub("<a*?>", "\\underline{\\texttt{", htmlString)
htmlString = gsub("</a>", "}}", htmlString)
htmlString = gsub("<sup>", "\\textsuperscript{", htmlString)
htmlString = gsub("</sup>", "}", htmlString)
htmlString = gsub("<.*?>", "", htmlString)
return(htmlString)
}

input <- read_csv(
file = 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/file.csv'
)

input <- input %>% mutate(
CleanSummary = Summary %>% cleanFun()
)

output <- 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/output.tex'

# LaTeX document preamble
cat(
paste(
'\documentclass{article}',
'\usepackage[utf8]{inputenc}',
'\usepackage[T1]{fontenc}',
'\begin{document}',
sep = 'n' # line-break
),
file = output
)

# LaTeX document body
for (cur_item in 1:nrow(input)) {

cat(
paste0(
'nn\clearpage',
'nn\section{', input$Title[cur_item], '}',
'n\subsection{by ', input$Author[cur_item], '}',
'nSummary: ', input$CleanSummary[cur_item],
'n', # line-break
'nMetadata: ', input$Metadata[cur_item]
),
file = output,
append = TRUE
)

}

# LaTeX document end
cat(
'nn\end{document}',
file = output,
append = TRUE
)


It produces, as output.tex a file that you can compile using LaTeX without having to process it entirely using datatool:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
begin{document}

clearpage

section{2666}
subsection{by Roberto Bolano}
Summary: Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the "total novel," 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.

Metadata: 7, 98213

clearpage

section{All About Love}
subsection{by Bell Hooks}
Summary: We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.

Metadata: 1, 75014

clearpage

[...]

end{document}





share|improve this answer























  • Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
    – user3445853
    Nov 20 at 22:59










  • Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
    – user3445853
    Nov 20 at 23:04










  • @user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
    – Werner
    Nov 21 at 1:50










  • sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
    – user3445853
    Nov 21 at 11:56










  • [Previous was @werner but comment can onyl be edited for 5min.]
    – user3445853
    Nov 21 at 14:14













up vote
0
down vote



accepted







up vote
0
down vote



accepted






The following LaTeX code takes a CSV as input and outputs a single page per row based on the content within the input file.



enter image description here



documentclass{article}

usepackage{filecontents}
% https://www.powells.com/25-books-to-read-before-you-die
begin{filecontents*}{file.csv}
Number,Title,Author,Summary,Metadata
1,2666,Roberto Bolano,"Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the ""total novel,"" 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.","7, 98213"
2,All About Love,Bell Hooks,"We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.","1, 75014"
3,Desert Solitaire,Edward Abbey,"No author encapsulated and celebrated the American Southwest more engagingly than iconoclast and raconteur Edward Abbey. Desert Solitaire: A Season in the Wilderness - now nearly a half-century old - is a classic of environmental writing. In this autobiographical work, Abbey chronicles his time as a park ranger and reflects on landscape, culture, politics, tourism, environmental disregard, and degradation - doing so with a unique blend of ornery charm and breathtaking description. Though set in his beloved Southwest, Desert Solitaire beautifully and brashly captures the essence of the American outdoors, replete with disdain for those who'd seek to spoil its natural wonder.","10, 57475"
4,Disgrace,JM Coetzee,"One afternoon while talking with a friend about books, I wondered how to best describe my experience of reading Disgrace, and this is what I came up with: it's like a finely crafted, very sharp knife resting gently against your skin. The uneasiness and suspense are there from the beginning, made all the more powerful by Coetzee's control and use of spare language, and you never really take a deep breath until it's all over. Set in modern South Africa, the book explores what it's like to personally confront deep prejudices. Prejudices of gender, sexuality, class, and race. Far from being a politically correct diatribe, this novel is about how we cope, how we survive as humans, and it forces the reader to reflect upon what seems at first a very twisted reality. For each of the characters in this astonishing novel, redemption is attained through what becomes the very reshaping of their souls.","4, 3245"
5,Geek Love,Katherine Dunn,"This is the book I recommend more than any other - I can barely hold onto a copy of it because I am always giving it away to anyone who I think needs something that will blow the top of their skull off. On one level, it is the engaging, creepy, and extraordinary story of a family of purposely designed circus freaks, as told by the hunchback albino dwarf sister. On another level, it is a story about identity and belonging: How do you define yourself in terms of your family? Your culture? Your body? Your religion? How do you know what or who you really are?","74, 87170"
6,Gilead,Marilynne Robinson,"Set in 1956, Marilynne Robinson's Gilead is a letter from the elderly Reverend John Ames to his very young son. Ames has lived all of his life in Gilead, Iowa, and the novel delves into the history of the area through the characters of Ames's father and grandfather - also ministers, but deeply divided on ideas such as pacifism, duty, and the abolitionist movement. And eventually, when John Ames Boughton, Ames's namesake and godson, returns to Gilead, he brings up old tensions and sets events in motion that disturb Ames's formerly peaceful last days. Gilead is one of the most beautifully written books of the new century thus far, and Robinson's incredibly insightful grappling with faith, mortality, and what constitutes a meaningful life will resonate with readers across every spectrum.","88, 81905"
7,Giovanni's Room,James Baldwin,"It would be difficult to talk about James Baldwin's Giovanni's Room and not touch on the simple fact that this slim novel, published in 1956, is mainly a love story between two men. It seems impossible to think such a thing could be published pre-Stonewall, but such is the genius of Baldwin and the way he captures the complexities of desire, love, and the tragic cost that comes from not following your heart. ""Somebody…should have told us that not many people have ever died of love. But multitudes have perished…for the lack of it."" This emotional wonder of a book comes down to two things: love and death. And really, what else is there in life?","6, 53009"
8,A Good Man Is Hard To Find and Other Stories,Flannery O'Connor,"Flannery O'Connor's first short story collection, written in 1955, will knock you off your feet. Ruthless, penetrating, and loaded with subtext, A Good Man Is Hard to Find and Other Stories was brave for its time and feels just as consequential today. Writing in the Southern Gothic tradition in a style wholly her own, O'Connor creates characters that are misguided, stunted curiosities, but she manages to capture what's human in even the most despicable of people - which makes their doomed trajectories feel all the more tragic. And despite the disturbing events that unfold, the stories are a pleasure to read - they're infused with suspense, dark humor, and some of the most evocative imagery you'll encounter in literature. All this makes for a collection that never ceases to amaze - and begs to be reread.","40, 73776"
9,The Handmaid's Tale,Margaret Atwood,"Atwood's classic dystopian novel of a terrifying (and terrifyingly plausible) future America has rewarded rereading like no other book; I've probably read it 30 times by now. The world of the narrator, Offred (from ""Of Fred"" - women no longer have their own names), is chilling, but she is a magnificent survivor and chronicler, and the details of everything from mundane daily life to ritualized sex and violence to her reminiscences of the time before (our contemporary reality, as seen in the '80s) are absolutely realistic. The novel is as relevant today as ever; feminist backlashes continue to wax and wane, but women's rights remain in the spotlight. And despite its scenarios of great despair, The Handmaid's Tale is ultimately a hopeful book - Offred, and others, simply cannot be human without the possibility of hope, and therein lies the strength of the resistance. All of Atwood is worth reading, but this book best exemplifies the cultural and psychological impact that a work of fiction can create.","84, 46669"
10,The Hitchhikers Guide to the Galaxy,Douglas Adams,"Parodying practically every well-worn sci-fi plot device in existence, Adams's Hitchhiker's Guide to the Galaxy has become a classic in its own right. A hapless hero with astonishing luck? Ill-tempered aliens hell-bent on destroying Earth? Pithy advice (e.g., ""DON'T PANIC"")? Check, check, and check - and so much more. Even non–sci-fi geeks will be charmed by this hilarious and endlessly entertaining read, with (of course) sequels following.","6, 19723"
11,In on a Winter's Night a Traveler,Italo Calvino,"For those with an amorous affair with books, If on a Winter's Night a Traveler may well be the ultimate love letter to the reader. Calvino's novel is a masterfully created, startlingly unique work of fiction. Told alternately in second- and third-person narratives, the book is a fascinating exploration of the relationship between the author and the reader - weaving together seemingly unrelated tales, all of which relate directly to you, the reader. At its core is an ingenious concept the likes of which could have only come from the unparalleled imagination of Calvino. By the time you reach its dazzling conclusion, you'll be wishing you could somehow read it again for the very first time.","72, 93697"
12,Infinite Jest,David Foster Wallace,"Infinite Jest is unique; it was bred in the optimism and new frontiersmanship of the dot-com 1990s but was simultaneously an early omen of where we are today. It looks into our present beyond what were only horizons when it was written: the tensions of a global economy, the opiate of on-demand entertainment, the near-impossible pursuit of greatness in a winner-take-all society. Tennis phenoms struggle in an absurdly demanding academy and recovering addicts search for something strong enough to help them through, all while a cadre of legless Quebecois assassins search for a movie so entertaining that they plan to use it as a weapon. At turns madcap and heart-wrenching, this is the tour-de-force novel of the forces that have shaped our new millennium and will likely continue shaping it for decades to come.","93, 66226"
13,The Left Hand of Darkness,Ursula K Le Guin,"Not only is The Left Hand of Darkness a masterpiece of ideas, invention, and language, but it takes conventional assumptions about gender and grinds them into a fine, powdery dust. Published in 1969, the book won both the Hugo and Nebula Awards and went on to become one of the keystones of science fiction. It tells the story of an ethnologist sent to another planet, but it is Le Guin's powers of imagination that turn The Left Hand of Darkness into something truly transcendent.","44, 11458"
14,Lolita,Vladimir Nabokov,"Why should everyone read a book about a pedophile's obsessive and frankly gross relationship with a little girl? Because if you are a reader - a lover of words, puns, witticisms, metaphors, and allusions - Lolita is a literary masterpiece that can't be passed over in a fit of queasy morality. Humbert Humbert, the novel's unreliable narrator, knows that he's a despicable pervert and yet the reader can't help enjoying him as he surveys post-war America and little Lolita with the droll, cynical eye of a European expat adrift in a tawdry nation, and stuck irrevocably - and irredeemably - in the memory of an adolescent love affair. Please, ignore the critics: Lolita isn't a morality tale and it isn't a love story. It's an unabashed look at a deviant mind written in some of the most deft and beautiful English ever published.","16, 91172"
15,Man's Search for Meaning,Viktor E Frankl,"Man's Search for Meaning is like nothing you've ever read before. The first half of the book depicts Dr. Frankl's four years losing everything in concentration camps - a description so hellish, it leaves you desolate. Shattered by his Holocaust experiences, Frankl struggles to survive after he is freed. In the second half of the book, Frankl shows how that period of his life informs and develops his theory of ""logotherapy"" - he asserts that life is about finding meaning, what is meaningful to each individual. As excruciating as his experiences are, Frankl's theory is full of love; he is able to find redemption for himself and others. This book is beautifully life-changing.","16, 23912"
16,Maus,Art Spiegelman,"The twofold brilliance of Art Spiegelman's groundbreaking, autobiographical Maus is the graphic novel's lack of sentimentality and Spiegelman's self-portrait as a secondhand Holocaust survivor. The Holocaust is a widely used trope in Jewish American writing and although Spiegelman treats the subject with the compassion and historical sensitivity it merits, Maus avoids the themes of victimization and historical exceptionalism that render much Holocaust literature precious and insulated from the present. Instead, Spiegelman gives his characters the dignity of fully fleshed, complicated personalities and shows - in sometimes painful and unappealing ways - how his parents' Holocaust seeped into his childhood and haunts his being.","97, 85306"
17,Never Let Me Go,Kazuo Ishiguro,"This is the kind of book that captures you so completely you find yourself reading it at work with the book covering your keyboard, hoping no one notices but also not really caring if you get fired. It's a subtle sci-fi story about youth, freedom, and a lot of other good stuff - too much more about the plot might take something away from the magical, transformative experience of reading it. Instead, I will say that the honest way Never Let Me Go deals with love and disappointment makes it a book that anyone who ever plans to love another person should probably read immediately. ","26, 13564"
18,A People's History of the United States,Howard Zinn,"While some of the revelations contained within this classic by Howard Zinn have become familiar since the nearly 35 years after it was published (thanks in part to this book), it is to this day an astonishing and eye-opening read. Several revisions later, it remains a seminal work, in stark contrast to the whitewashed (pun intended) American history most of us learned by rote in school. It's regretful with Zinn's passing in 2010 that new revisions have ceased for future generations to discover.","96, 17837"
19,The Phantom Tollbooth,Norton Juster,"The Phantom Tollbooth is the story of Milo, a very bored boy who comes home one day to find a magical tollbooth in his room. When Milo drives his car through the tollbooth gate, he finds himself in the Lands Beyond, a country inhabited by living language in the forms of animals, magicians, royalty, mountains, seas, and cities. From Tock the Watchdog to the listless region of The Doldrums, Milo shakes off boredom as he pursues the kidnapped Princesses Rhyme and Reason and restores peace to the Lands (currently in the clutches of the warring princes, Azaz of Dictionopolis and the Mathemagician of Digitopolis, along with a pack of demons). What sets The Phantom Tollbooth apart from other wonderful swashbuckling middle-readers is that it's also about the transformative power of language: open a book (or drive through a ""tollbooth"") and even the dreariest day dissolves into the din and glory of adventure.","20, 88130"
20,Poems,Elizabeth Bishop,"Elizabeth Bishop's poetry is dearly loved amongst her fans but perhaps not as well-known as it should be; for one of America's towering talents of the 20th century, she is not read nearly as much as Eliot or Whitman, or even cummings. That may be in part because of her relatively slim output - this volume of all her poetic works clocks in at only 368 pages. But the care she took with her poetry is evident; every word is perfectly chosen, none wasted or missing. Her work is fiercely intelligent, poignant, surprising, plainspoken, and wrought from imagery both familiar and extraordinary. A must-read for anyone who is interested in poetry, language, or indeed literature at all, Bishop's Poems speaks deeply to what makes us human. ","54, 23476"
21,Slaughterhouse-Five,Kurt Vonnegut,"What Kurt Vonnegut set out to do was write a book about war, and in particular the firebombing of Dresden in World War II. What he ended up doing was writing clean around it - traveling in and out of time warps, bouncing on and off the earth, sometimes setting down on the planet Tralfamadore, millions of miles away from Dresden and millions of miles away from war. What he created was a masterpiece of satire in which every crazy, clever moment, every whimsical line, no matter how deceptively light, is imbued with the sorrow and the starkness of the atrocity Vonnegut himself witnessed in that very real war.","88, 62848"
22,Things Fall Apart,Chinua Achebe,"Before Things Fall Apart was published in 1958, few novels existed in English that depicted African life from the African perspective. And while the book has paved the way for countless authors since, Chinua Achebe's illuminating work remains a classic of modern African literature. Drawing on the history and customs passed down to him, Achebe tells the tale Okonkwo, a strong-willed member of a late-19th-century Nigerian village. As we follow Okonkwo's story, we get a glimpse of the intricacies of village life and the complex social structures that come into play. We then see the devastating effects of European colonization on the region and on Okonkwo himself, whose rise and fall become intertwined with the changing power dynamics. Things Fall Apart is essential reading for anyone who wants a more nuanced understanding of other ways of life, of culture clashes, of what being civilized really entails.","16, 94548"
23,To Kill a Mockingbird,Harper Lee,"While To Kill a Mockingbird is a favorite book of pretty much everyone who has read it, it's important to remember that it continues to be subversive and challenging to the status quo. The protagonist is a young girl named Scout and except for her father, all the main characters in the book are marginalized by the power structure of their town - a structure that still exists nearly everywhere - where wealthy white men control the lives of everyone else, and even the members of that group who want to use their status for something honorable, like Scout's father Atticus, cannot win against the flattening wave of that power. Until something about that structure really changes, this book will remain required reading for every person in America.","1, 93991"
24,Where the Wild Things Are,Maurice Sendak,"We all hold our favorite childhood books dear, but there's a reason Where the Wild Things Are is one of the most beloved picture books of all time. Of course it's about Maurice Sendak's whimsy, his spare poetry, his imagination. Of course it's about his impeccably detailed illustrations, depicting the beauty of a night of wild rumpus and the elegant fiendishness of wild things who gnash their terrible teeth and roll their terrible eyes. But mostly I think it's because underneath the boundless (yet beautifully bounded) inventiveness of Sendak's world, we see - and remember - exactly what it is to be a child.","60, 64838"
25,The Wind-Up Bird Chronicle,Haruki Murakami,"Known for his beautiful, haunting, lyrical, and - at times - funny surrealistic stylings, Haruki Murakami is one of the most beloved Japanese authors in the Western world. Although infused with the pop culture of the West, his writing remains at its core firmly rooted in Japan. And as modern as his style is, his work draws upon the country's past while delving deep into the Japanese psyche. The Wind-Up Bird Chronicle is pure Murakami - a vast, enchanting mystery filled with dreamlike surrealism. Considered by many to be his best work, the novel tackles themes as varied as the nature of consciousness, romantic disappointment, and the lingering wounds of World War II. Readers will eagerly want to unravel this intricate, multi-layered tale.","56, 50224"
end{filecontents*}

usepackage{datatool}
setlength{parindent}{0pt} % Remove paragraph indentation

begin{document}

% Load CSV file
DTLloaddb
{file} % DB name
{file.csv} % filename

DTLforeach
{file} % DB name
{Title=Title,
Author=Author,
Summary=Summary,
Metadata=Metadata%
}% Assignment list
{%
section*{Title}
subsection*{by Author}

Summary: Summary

Metadata: Metadata

hrulefill
clearpage
}

end{document}




Let's assume file.csv contains the above list of titles, authors, summaries, ... Then you can clean any HTML code contained within the summaries using the following R script:



library(tidyverse)

# [Removing html tags from a string in R](https://stackoverflow.com/q/17227294/914686)
cleanFun <- function(htmlString) {
htmlString = gsub("&nbsp;", " ", htmlString)
htmlString = gsub("&gt;", "$>$", htmlString)
htmlString = gsub("&lt;", "$<$", htmlString)
htmlString = gsub("&amp;", "&", htmlString)
htmlString = gsub("&", "\\&", htmlString)
htmlString = gsub("@;", "\\@", htmlString)
htmlString = gsub("<i>", "\\textit{", htmlString)
htmlString = gsub("</i>", "}", htmlString)
htmlString = gsub("<b>", "\\textbf{", htmlString)
htmlString = gsub("</b>", "}", htmlString)
htmlString = gsub("<em>", "\\emph{", htmlString)
htmlString = gsub("</em>", "}", htmlString)
htmlString = gsub("<strong>", "\\textbf{", htmlString)
htmlString = gsub("</strong>", "}", htmlString)
htmlString = gsub("<u>", "\\underline{", htmlString)
htmlString = gsub("</u>", "}", htmlString)
htmlString = gsub("<a*?>", "\\underline{\\texttt{", htmlString)
htmlString = gsub("</a>", "}}", htmlString)
htmlString = gsub("<sup>", "\\textsuperscript{", htmlString)
htmlString = gsub("</sup>", "}", htmlString)
htmlString = gsub("<.*?>", "", htmlString)
return(htmlString)
}

input <- read_csv(
file = 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/file.csv'
)

input <- input %>% mutate(
CleanSummary = Summary %>% cleanFun()
)

output <- 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/output.tex'

# LaTeX document preamble
cat(
paste(
'\documentclass{article}',
'\usepackage[utf8]{inputenc}',
'\usepackage[T1]{fontenc}',
'\begin{document}',
sep = 'n' # line-break
),
file = output
)

# LaTeX document body
for (cur_item in 1:nrow(input)) {

cat(
paste0(
'nn\clearpage',
'nn\section{', input$Title[cur_item], '}',
'n\subsection{by ', input$Author[cur_item], '}',
'nSummary: ', input$CleanSummary[cur_item],
'n', # line-break
'nMetadata: ', input$Metadata[cur_item]
),
file = output,
append = TRUE
)

}

# LaTeX document end
cat(
'nn\end{document}',
file = output,
append = TRUE
)


It produces, as output.tex a file that you can compile using LaTeX without having to process it entirely using datatool:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
begin{document}

clearpage

section{2666}
subsection{by Roberto Bolano}
Summary: Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the "total novel," 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.

Metadata: 7, 98213

clearpage

section{All About Love}
subsection{by Bell Hooks}
Summary: We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.

Metadata: 1, 75014

clearpage

[...]

end{document}





share|improve this answer














The following LaTeX code takes a CSV as input and outputs a single page per row based on the content within the input file.



enter image description here



documentclass{article}

usepackage{filecontents}
% https://www.powells.com/25-books-to-read-before-you-die
begin{filecontents*}{file.csv}
Number,Title,Author,Summary,Metadata
1,2666,Roberto Bolano,"Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the ""total novel,"" 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.","7, 98213"
2,All About Love,Bell Hooks,"We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.","1, 75014"
3,Desert Solitaire,Edward Abbey,"No author encapsulated and celebrated the American Southwest more engagingly than iconoclast and raconteur Edward Abbey. Desert Solitaire: A Season in the Wilderness - now nearly a half-century old - is a classic of environmental writing. In this autobiographical work, Abbey chronicles his time as a park ranger and reflects on landscape, culture, politics, tourism, environmental disregard, and degradation - doing so with a unique blend of ornery charm and breathtaking description. Though set in his beloved Southwest, Desert Solitaire beautifully and brashly captures the essence of the American outdoors, replete with disdain for those who'd seek to spoil its natural wonder.","10, 57475"
4,Disgrace,JM Coetzee,"One afternoon while talking with a friend about books, I wondered how to best describe my experience of reading Disgrace, and this is what I came up with: it's like a finely crafted, very sharp knife resting gently against your skin. The uneasiness and suspense are there from the beginning, made all the more powerful by Coetzee's control and use of spare language, and you never really take a deep breath until it's all over. Set in modern South Africa, the book explores what it's like to personally confront deep prejudices. Prejudices of gender, sexuality, class, and race. Far from being a politically correct diatribe, this novel is about how we cope, how we survive as humans, and it forces the reader to reflect upon what seems at first a very twisted reality. For each of the characters in this astonishing novel, redemption is attained through what becomes the very reshaping of their souls.","4, 3245"
5,Geek Love,Katherine Dunn,"This is the book I recommend more than any other - I can barely hold onto a copy of it because I am always giving it away to anyone who I think needs something that will blow the top of their skull off. On one level, it is the engaging, creepy, and extraordinary story of a family of purposely designed circus freaks, as told by the hunchback albino dwarf sister. On another level, it is a story about identity and belonging: How do you define yourself in terms of your family? Your culture? Your body? Your religion? How do you know what or who you really are?","74, 87170"
6,Gilead,Marilynne Robinson,"Set in 1956, Marilynne Robinson's Gilead is a letter from the elderly Reverend John Ames to his very young son. Ames has lived all of his life in Gilead, Iowa, and the novel delves into the history of the area through the characters of Ames's father and grandfather - also ministers, but deeply divided on ideas such as pacifism, duty, and the abolitionist movement. And eventually, when John Ames Boughton, Ames's namesake and godson, returns to Gilead, he brings up old tensions and sets events in motion that disturb Ames's formerly peaceful last days. Gilead is one of the most beautifully written books of the new century thus far, and Robinson's incredibly insightful grappling with faith, mortality, and what constitutes a meaningful life will resonate with readers across every spectrum.","88, 81905"
7,Giovanni's Room,James Baldwin,"It would be difficult to talk about James Baldwin's Giovanni's Room and not touch on the simple fact that this slim novel, published in 1956, is mainly a love story between two men. It seems impossible to think such a thing could be published pre-Stonewall, but such is the genius of Baldwin and the way he captures the complexities of desire, love, and the tragic cost that comes from not following your heart. ""Somebody…should have told us that not many people have ever died of love. But multitudes have perished…for the lack of it."" This emotional wonder of a book comes down to two things: love and death. And really, what else is there in life?","6, 53009"
8,A Good Man Is Hard To Find and Other Stories,Flannery O'Connor,"Flannery O'Connor's first short story collection, written in 1955, will knock you off your feet. Ruthless, penetrating, and loaded with subtext, A Good Man Is Hard to Find and Other Stories was brave for its time and feels just as consequential today. Writing in the Southern Gothic tradition in a style wholly her own, O'Connor creates characters that are misguided, stunted curiosities, but she manages to capture what's human in even the most despicable of people - which makes their doomed trajectories feel all the more tragic. And despite the disturbing events that unfold, the stories are a pleasure to read - they're infused with suspense, dark humor, and some of the most evocative imagery you'll encounter in literature. All this makes for a collection that never ceases to amaze - and begs to be reread.","40, 73776"
9,The Handmaid's Tale,Margaret Atwood,"Atwood's classic dystopian novel of a terrifying (and terrifyingly plausible) future America has rewarded rereading like no other book; I've probably read it 30 times by now. The world of the narrator, Offred (from ""Of Fred"" - women no longer have their own names), is chilling, but she is a magnificent survivor and chronicler, and the details of everything from mundane daily life to ritualized sex and violence to her reminiscences of the time before (our contemporary reality, as seen in the '80s) are absolutely realistic. The novel is as relevant today as ever; feminist backlashes continue to wax and wane, but women's rights remain in the spotlight. And despite its scenarios of great despair, The Handmaid's Tale is ultimately a hopeful book - Offred, and others, simply cannot be human without the possibility of hope, and therein lies the strength of the resistance. All of Atwood is worth reading, but this book best exemplifies the cultural and psychological impact that a work of fiction can create.","84, 46669"
10,The Hitchhikers Guide to the Galaxy,Douglas Adams,"Parodying practically every well-worn sci-fi plot device in existence, Adams's Hitchhiker's Guide to the Galaxy has become a classic in its own right. A hapless hero with astonishing luck? Ill-tempered aliens hell-bent on destroying Earth? Pithy advice (e.g., ""DON'T PANIC"")? Check, check, and check - and so much more. Even non–sci-fi geeks will be charmed by this hilarious and endlessly entertaining read, with (of course) sequels following.","6, 19723"
11,In on a Winter's Night a Traveler,Italo Calvino,"For those with an amorous affair with books, If on a Winter's Night a Traveler may well be the ultimate love letter to the reader. Calvino's novel is a masterfully created, startlingly unique work of fiction. Told alternately in second- and third-person narratives, the book is a fascinating exploration of the relationship between the author and the reader - weaving together seemingly unrelated tales, all of which relate directly to you, the reader. At its core is an ingenious concept the likes of which could have only come from the unparalleled imagination of Calvino. By the time you reach its dazzling conclusion, you'll be wishing you could somehow read it again for the very first time.","72, 93697"
12,Infinite Jest,David Foster Wallace,"Infinite Jest is unique; it was bred in the optimism and new frontiersmanship of the dot-com 1990s but was simultaneously an early omen of where we are today. It looks into our present beyond what were only horizons when it was written: the tensions of a global economy, the opiate of on-demand entertainment, the near-impossible pursuit of greatness in a winner-take-all society. Tennis phenoms struggle in an absurdly demanding academy and recovering addicts search for something strong enough to help them through, all while a cadre of legless Quebecois assassins search for a movie so entertaining that they plan to use it as a weapon. At turns madcap and heart-wrenching, this is the tour-de-force novel of the forces that have shaped our new millennium and will likely continue shaping it for decades to come.","93, 66226"
13,The Left Hand of Darkness,Ursula K Le Guin,"Not only is The Left Hand of Darkness a masterpiece of ideas, invention, and language, but it takes conventional assumptions about gender and grinds them into a fine, powdery dust. Published in 1969, the book won both the Hugo and Nebula Awards and went on to become one of the keystones of science fiction. It tells the story of an ethnologist sent to another planet, but it is Le Guin's powers of imagination that turn The Left Hand of Darkness into something truly transcendent.","44, 11458"
14,Lolita,Vladimir Nabokov,"Why should everyone read a book about a pedophile's obsessive and frankly gross relationship with a little girl? Because if you are a reader - a lover of words, puns, witticisms, metaphors, and allusions - Lolita is a literary masterpiece that can't be passed over in a fit of queasy morality. Humbert Humbert, the novel's unreliable narrator, knows that he's a despicable pervert and yet the reader can't help enjoying him as he surveys post-war America and little Lolita with the droll, cynical eye of a European expat adrift in a tawdry nation, and stuck irrevocably - and irredeemably - in the memory of an adolescent love affair. Please, ignore the critics: Lolita isn't a morality tale and it isn't a love story. It's an unabashed look at a deviant mind written in some of the most deft and beautiful English ever published.","16, 91172"
15,Man's Search for Meaning,Viktor E Frankl,"Man's Search for Meaning is like nothing you've ever read before. The first half of the book depicts Dr. Frankl's four years losing everything in concentration camps - a description so hellish, it leaves you desolate. Shattered by his Holocaust experiences, Frankl struggles to survive after he is freed. In the second half of the book, Frankl shows how that period of his life informs and develops his theory of ""logotherapy"" - he asserts that life is about finding meaning, what is meaningful to each individual. As excruciating as his experiences are, Frankl's theory is full of love; he is able to find redemption for himself and others. This book is beautifully life-changing.","16, 23912"
16,Maus,Art Spiegelman,"The twofold brilliance of Art Spiegelman's groundbreaking, autobiographical Maus is the graphic novel's lack of sentimentality and Spiegelman's self-portrait as a secondhand Holocaust survivor. The Holocaust is a widely used trope in Jewish American writing and although Spiegelman treats the subject with the compassion and historical sensitivity it merits, Maus avoids the themes of victimization and historical exceptionalism that render much Holocaust literature precious and insulated from the present. Instead, Spiegelman gives his characters the dignity of fully fleshed, complicated personalities and shows - in sometimes painful and unappealing ways - how his parents' Holocaust seeped into his childhood and haunts his being.","97, 85306"
17,Never Let Me Go,Kazuo Ishiguro,"This is the kind of book that captures you so completely you find yourself reading it at work with the book covering your keyboard, hoping no one notices but also not really caring if you get fired. It's a subtle sci-fi story about youth, freedom, and a lot of other good stuff - too much more about the plot might take something away from the magical, transformative experience of reading it. Instead, I will say that the honest way Never Let Me Go deals with love and disappointment makes it a book that anyone who ever plans to love another person should probably read immediately. ","26, 13564"
18,A People's History of the United States,Howard Zinn,"While some of the revelations contained within this classic by Howard Zinn have become familiar since the nearly 35 years after it was published (thanks in part to this book), it is to this day an astonishing and eye-opening read. Several revisions later, it remains a seminal work, in stark contrast to the whitewashed (pun intended) American history most of us learned by rote in school. It's regretful with Zinn's passing in 2010 that new revisions have ceased for future generations to discover.","96, 17837"
19,The Phantom Tollbooth,Norton Juster,"The Phantom Tollbooth is the story of Milo, a very bored boy who comes home one day to find a magical tollbooth in his room. When Milo drives his car through the tollbooth gate, he finds himself in the Lands Beyond, a country inhabited by living language in the forms of animals, magicians, royalty, mountains, seas, and cities. From Tock the Watchdog to the listless region of The Doldrums, Milo shakes off boredom as he pursues the kidnapped Princesses Rhyme and Reason and restores peace to the Lands (currently in the clutches of the warring princes, Azaz of Dictionopolis and the Mathemagician of Digitopolis, along with a pack of demons). What sets The Phantom Tollbooth apart from other wonderful swashbuckling middle-readers is that it's also about the transformative power of language: open a book (or drive through a ""tollbooth"") and even the dreariest day dissolves into the din and glory of adventure.","20, 88130"
20,Poems,Elizabeth Bishop,"Elizabeth Bishop's poetry is dearly loved amongst her fans but perhaps not as well-known as it should be; for one of America's towering talents of the 20th century, she is not read nearly as much as Eliot or Whitman, or even cummings. That may be in part because of her relatively slim output - this volume of all her poetic works clocks in at only 368 pages. But the care she took with her poetry is evident; every word is perfectly chosen, none wasted or missing. Her work is fiercely intelligent, poignant, surprising, plainspoken, and wrought from imagery both familiar and extraordinary. A must-read for anyone who is interested in poetry, language, or indeed literature at all, Bishop's Poems speaks deeply to what makes us human. ","54, 23476"
21,Slaughterhouse-Five,Kurt Vonnegut,"What Kurt Vonnegut set out to do was write a book about war, and in particular the firebombing of Dresden in World War II. What he ended up doing was writing clean around it - traveling in and out of time warps, bouncing on and off the earth, sometimes setting down on the planet Tralfamadore, millions of miles away from Dresden and millions of miles away from war. What he created was a masterpiece of satire in which every crazy, clever moment, every whimsical line, no matter how deceptively light, is imbued with the sorrow and the starkness of the atrocity Vonnegut himself witnessed in that very real war.","88, 62848"
22,Things Fall Apart,Chinua Achebe,"Before Things Fall Apart was published in 1958, few novels existed in English that depicted African life from the African perspective. And while the book has paved the way for countless authors since, Chinua Achebe's illuminating work remains a classic of modern African literature. Drawing on the history and customs passed down to him, Achebe tells the tale Okonkwo, a strong-willed member of a late-19th-century Nigerian village. As we follow Okonkwo's story, we get a glimpse of the intricacies of village life and the complex social structures that come into play. We then see the devastating effects of European colonization on the region and on Okonkwo himself, whose rise and fall become intertwined with the changing power dynamics. Things Fall Apart is essential reading for anyone who wants a more nuanced understanding of other ways of life, of culture clashes, of what being civilized really entails.","16, 94548"
23,To Kill a Mockingbird,Harper Lee,"While To Kill a Mockingbird is a favorite book of pretty much everyone who has read it, it's important to remember that it continues to be subversive and challenging to the status quo. The protagonist is a young girl named Scout and except for her father, all the main characters in the book are marginalized by the power structure of their town - a structure that still exists nearly everywhere - where wealthy white men control the lives of everyone else, and even the members of that group who want to use their status for something honorable, like Scout's father Atticus, cannot win against the flattening wave of that power. Until something about that structure really changes, this book will remain required reading for every person in America.","1, 93991"
24,Where the Wild Things Are,Maurice Sendak,"We all hold our favorite childhood books dear, but there's a reason Where the Wild Things Are is one of the most beloved picture books of all time. Of course it's about Maurice Sendak's whimsy, his spare poetry, his imagination. Of course it's about his impeccably detailed illustrations, depicting the beauty of a night of wild rumpus and the elegant fiendishness of wild things who gnash their terrible teeth and roll their terrible eyes. But mostly I think it's because underneath the boundless (yet beautifully bounded) inventiveness of Sendak's world, we see - and remember - exactly what it is to be a child.","60, 64838"
25,The Wind-Up Bird Chronicle,Haruki Murakami,"Known for his beautiful, haunting, lyrical, and - at times - funny surrealistic stylings, Haruki Murakami is one of the most beloved Japanese authors in the Western world. Although infused with the pop culture of the West, his writing remains at its core firmly rooted in Japan. And as modern as his style is, his work draws upon the country's past while delving deep into the Japanese psyche. The Wind-Up Bird Chronicle is pure Murakami - a vast, enchanting mystery filled with dreamlike surrealism. Considered by many to be his best work, the novel tackles themes as varied as the nature of consciousness, romantic disappointment, and the lingering wounds of World War II. Readers will eagerly want to unravel this intricate, multi-layered tale.","56, 50224"
end{filecontents*}

usepackage{datatool}
setlength{parindent}{0pt} % Remove paragraph indentation

begin{document}

% Load CSV file
DTLloaddb
{file} % DB name
{file.csv} % filename

DTLforeach
{file} % DB name
{Title=Title,
Author=Author,
Summary=Summary,
Metadata=Metadata%
}% Assignment list
{%
section*{Title}
subsection*{by Author}

Summary: Summary

Metadata: Metadata

hrulefill
clearpage
}

end{document}




Let's assume file.csv contains the above list of titles, authors, summaries, ... Then you can clean any HTML code contained within the summaries using the following R script:



library(tidyverse)

# [Removing html tags from a string in R](https://stackoverflow.com/q/17227294/914686)
cleanFun <- function(htmlString) {
htmlString = gsub("&nbsp;", " ", htmlString)
htmlString = gsub("&gt;", "$>$", htmlString)
htmlString = gsub("&lt;", "$<$", htmlString)
htmlString = gsub("&amp;", "&", htmlString)
htmlString = gsub("&", "\\&", htmlString)
htmlString = gsub("@;", "\\@", htmlString)
htmlString = gsub("<i>", "\\textit{", htmlString)
htmlString = gsub("</i>", "}", htmlString)
htmlString = gsub("<b>", "\\textbf{", htmlString)
htmlString = gsub("</b>", "}", htmlString)
htmlString = gsub("<em>", "\\emph{", htmlString)
htmlString = gsub("</em>", "}", htmlString)
htmlString = gsub("<strong>", "\\textbf{", htmlString)
htmlString = gsub("</strong>", "}", htmlString)
htmlString = gsub("<u>", "\\underline{", htmlString)
htmlString = gsub("</u>", "}", htmlString)
htmlString = gsub("<a*?>", "\\underline{\\texttt{", htmlString)
htmlString = gsub("</a>", "}}", htmlString)
htmlString = gsub("<sup>", "\\textsuperscript{", htmlString)
htmlString = gsub("</sup>", "}", htmlString)
htmlString = gsub("<.*?>", "", htmlString)
return(htmlString)
}

input <- read_csv(
file = 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/file.csv'
)

input <- input %>% mutate(
CleanSummary = Summary %>% cleanFun()
)

output <- 'C:/Users/Werner/Documents/Research/LaTeX/latex_stuff/output.tex'

# LaTeX document preamble
cat(
paste(
'\documentclass{article}',
'\usepackage[utf8]{inputenc}',
'\usepackage[T1]{fontenc}',
'\begin{document}',
sep = 'n' # line-break
),
file = output
)

# LaTeX document body
for (cur_item in 1:nrow(input)) {

cat(
paste0(
'nn\clearpage',
'nn\section{', input$Title[cur_item], '}',
'n\subsection{by ', input$Author[cur_item], '}',
'nSummary: ', input$CleanSummary[cur_item],
'n', # line-break
'nMetadata: ', input$Metadata[cur_item]
),
file = output,
append = TRUE
)

}

# LaTeX document end
cat(
'nn\end{document}',
file = output,
append = TRUE
)


It produces, as output.tex a file that you can compile using LaTeX without having to process it entirely using datatool:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
begin{document}

clearpage

section{2666}
subsection{by Roberto Bolano}
Summary: Completed in 2003 shortly before his death, 2666 is not only Roberto Bolano's masterpiece but also one of the finest and most important novels of the 21st century. It's an entire world unto itself, one - not unlike our own - filled with horror, neglect, depravity, brilliance, and beauty. Epic in scope and epitomizing the "total novel," 2666 fuses many different genres and styles to create a singular and unforgettable work of contemporary fiction. While Bolano's swan song marked the pinnacle of a sadly truncated literary career, his immense talent, creativity, and vision endure.

Metadata: 7, 98213

clearpage

section{All About Love}
subsection{by Bell Hooks}
Summary: We're taught to think of love as something that happens to us. It's a magical but altogether passive experience. In her deeply personal and emphatic All About Love, renowned social activist and feminist bell hooks asserts that, in fact, love is a choice we must all make and it's not nearly as abstract or elusive as many of us have come to believe. The book not only explores the role of love in our lives and the ways our culture has distorted its meaning, but guides us - with clear definitions and examples - toward a better understanding of how to cultivate it. If you've ever wondered why some relationships stand the test of time while others crumble, you should read this book.

Metadata: 1, 75014

clearpage

[...]

end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 27 at 22:41

























answered Nov 20 at 4:39









Werner

7,59342543




7,59342543












  • Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
    – user3445853
    Nov 20 at 22:59










  • Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
    – user3445853
    Nov 20 at 23:04










  • @user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
    – Werner
    Nov 21 at 1:50










  • sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
    – user3445853
    Nov 21 at 11:56










  • [Previous was @werner but comment can onyl be edited for 5min.]
    – user3445853
    Nov 21 at 14:14


















  • Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
    – user3445853
    Nov 20 at 22:59










  • Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
    – user3445853
    Nov 20 at 23:04










  • @user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
    – Werner
    Nov 21 at 1:50










  • sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
    – user3445853
    Nov 21 at 11:56










  • [Previous was @werner but comment can onyl be edited for 5min.]
    – user3445853
    Nov 21 at 14:14
















Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
– user3445853
Nov 20 at 22:59




Thanks so much! This is so elegant and simple, it almost has to work... I've run into various problems through the nature of the data: 500 lines where Summary is actually HTML input (bastardized by WordPress, e.g., newline = linebreak <br/>, two newlines = paragraph <p>). But some of it is in Russian. Lots of accented names (Turkish, Eastern-European, French,...). Little actual HTML, just <em> and <strong>. Using HTML-to-LaTex conversions seemed OK with a lot of hand-cleaning. And XeTeX for compiling. All in all after hours of kludging I'm not happy with my outcome (justify often failing)
– user3445853
Nov 20 at 22:59












Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
– user3445853
Nov 20 at 23:04




Mostly it works on say 50 lines at a time; when I try the full set it hangs for a long time then says that there is an extra } somewhere in the Datatool operation (no linenumber of the source of course). After conversion my datafile has 1149 instances of { as well as of }... there must be at least one LaTeX error somewhere, findable by halving the file I suppose.
– user3445853
Nov 20 at 23:04












@user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
– Werner
Nov 21 at 1:50




@user3445853: One can process the content with something else to remove all the HTML tags and then leave the processed output to be compiled with LaTeX. Do you have a sample of the input that I can work with? If so, post it to PasteBin.
– Werner
Nov 21 at 1:50












sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
– user3445853
Nov 21 at 11:56




sorry --- it's personal info so I can't paste (GDPR and all that). I'll see if I can make faux data; but as said it's WP-bastardized "HTML" input, Latin and Cyrilic (Russian) input, <i> , <em>, <strong>, <b> and <u> plus the usual paste-from-Word items (<span class="apple-converted-space">, <span lang="KR">, etc), orphaned anchors plus a few hyperlinks (mailto: or regular). Names with various accents (Spanish, Hungarian, ... ). But there must be some other gremlins I overlook here, as it doesn't compile! First I'll pursue the MailMerge suggestion (Office & WP looove standards, ouch).
– user3445853
Nov 21 at 11:56












[Previous was @werner but comment can onyl be edited for 5min.]
– user3445853
Nov 21 at 14:14




[Previous was @werner but comment can onyl be edited for 5min.]
– user3445853
Nov 21 at 14:14


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379670%2freasonable-tool-to-convert-a-spreadsheet-to-text-with-one-row-one-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin