Problem is, that Latex is telling me, that there is following Error at line \end{lstlisting}:
68: LaTeX Error: There's no line here to end.
\begin{figure}
\caption{Paragraph 1 - Code}
\begin{lstlisting}
[firstnumber=125]
def recextract(obj, arr, prefix):
#Recursively search for values of key in JSON tree.
if isinstance(obj, dict):
for k, v in obj.items():
if isinstance(v, (dict, list)):
recextract(v, arr, prefix+'_'+k)
else:
arr[prefix+'_'+k] = v
elif isinstance(obj, list):
for item in obj:
recextract(item, arr, prefix)
def parse_json(array_of_json):
arr = dict()
es_row = recextract(json.loads(array_of_json), arr, '')
return arr
prdd = rdd.map(lambda x: parse_json(x[1]))
df = prdd.toDF(sampleRatio=0.01)
df = df.cache()
df = df.toDF(*(c.replace('.', '_') for c in df.columns))
print(df.count())
\end{lstlisting}
\source{Zeppelin}
\label{fig:abb1}
\end{figure}
please help :)
I tried using the lstlisting as a figure, so I can have it numbered etc
You don't need the figure environment to have the listing numbered, see here. If you delete the figure environment (including label and caption) and change
\begin{lstlisting}[firstnumber=125]to\begin{lstlisting}[firstnumber=125, caption=Paragraph 1 - Code, label=fig:abb1]then you should no longer get an error message.Mini example: